I am using GraphDB free edition.
I wanted to create a user via REST API and found in the documentation that /rest/security/user/** could be used to create a user.
But what is ** in api endpoint and also how to create a user using the above endpoint? What should be the parameters and body for the POST request?
TIA.
You could create user using GraphDB REST API using following cURL request:
curl 'http://localhost:7201/rest/security/user/username' -H 'Origin:
http://localhost:7201' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: en-US,en;q=0.9' -H 'Content-Type: application/json;charset=UTF-8' -H
'Accept: application/json, text/plain, */*' -H 'Cache-Control: no-cache' -H 'Referer: http://localhost:7201/user/create' -H 'X-GraphDB-Repository:
repository name' -H 'X-GraphDB-Password: user password' -H 'DNT: 1' --data-binary '{"appSettings":
{"DEFAULT_SAMEAS":true,"DEFAULT_INFERENCE":true,"EXECUTE_COUNT":true,"IGNORE_SHARED_QUERIES":false},"grantedAuthorities":
["ROLE_USER","WRITE_REPO_*","READ_REPO_*"]}' --compressed
You should add -u admin username:password or send for example http://localhost:port number/rest/login POST request with "Content-Type", "application/json; charset=UTF-8", "Accept", "application/json" with JSONObject with registered admin user - username and password and will get header "Authorization" as result token generated for user and you should attach it like: 'Authorization: returned authorization header'.
Related
I have request in Insomnia. When I send it via Insomnia, no problemo. But when I generate source code for curl, it shows me this.
curl --request POST \
--url URL \
--header 'Authorization: bearer XXX' \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--cookie JSESSIONID=XXX \
--form datasetFile=#FOLDER/producthierarchyl1-1.zip
{"message":"Bad Request","logref":null,"path":null,"_embedded":{"errors":[{"message":"Required argument [Publisher datasetFile] not specified","logref":null,"path":"/datasetFile","_embedded":{},"_links":{}}]},"_links":{"self":{"href":"/data-api/public-api/v4/datasets/ingestion/","templated":false,"profile":null,"deprecation":null,"title":null,"hreflang":null,"type":null,"name":null}}}
Insomnia output is like this.
> POST PATH HTTP/2
> Host: URL
> user-agent: insomnia/2022.3.0
> cookie: JSESSIONID=XXX
> authorization: bearer XXX
> content-type: multipart/form-data; boundary=X-INSOMNIA-BOUNDARY
> accept: */*
> content-length: 407
* STATE: DO => DID handle 0x170404b14008; line 2077 (connection #27)
* multi changed, check CONNECT_PEND queue!
* STATE: DID => PERFORMING handle 0x170404b14008; line 2196 (connection #27)
| --X-INSOMNIA-BOUNDARY
| Content-Disposition: form-data; name="datasetFile"; filename="producthierarchyl1-1.zip"
| Content-Type: application/zip
| PK�QU�}�%+producthierarchyl1-1.csvUT բ�b
| --X-INSOMNIA-BOUNDARY--
* We are completely uploaded and fine
* HTTP/2 found, allow multiplexing
Where is the catch?
Thanks.
Remove the --header 'content-type: multipart/form-data; boundary=---011000010111000001101001 option.
It really should not be used like this: curl manages that header and the boundary on its own so changing it should only be done in the rare event you truly want and need to fiddle around with it.
A more minor second thing: --request POST should be dropped from the command line, as it is superfluous and easily cause problems if you add --location later on.
Updated
This flaw is said to have been fixed in a later version of Insomnia
For any folks bumping into this issue again, this answer correctly explains the reason for the problem.
Fortunately this should only be reproducible in versions 2022.3.0 and older versions of Insomnia.
If you use the latest one, 2022.5.1, the generated curl will no longer have this problem, example of a multipart request generated:
curl --request GET \
--url http://mockbin.org/request/anything \
--header 'Content-Type: multipart/form-data' \
--form test=test \
--form test=#/Users/yourUserName/Desktop/somefile.txt
curl -X GET "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=LON&destination=NYC&departureDate=2022-10-01&oneWay=true&nonStop=false&viewBy=DATE" -H "accept: application/vnd.amadeus+json" -H "Authorization: Bearer XXXXXXXXXXXXXXXXXXX"
it is under internal analysis. The service will return soon in Test environment.
https://github.com/amadeus4dev/amadeus-code-examples/blob/master/flight_cheapest_date_search/v1/get/curl/flight_cheapest_date_search.sh
curl -X GET "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=MUC" -H "Authorization: Bearer $ACCESS_TOKEN" -k
{"errors":[{"status":404,"code":6003,"title":"ITEM/DATA NOT FOUND OR DATA NOT EXISTING","detail":"No price result found"},{"status":404,"code":6003,"title":"ITEM/DATA NOT FOUND OR DATA NOT EXISTING","detail":"No price results found for input combined criteria"}]}
please help i am getting an error message when i tried to convert a curl post request into vb.net
Curl
curl -X GET --header 'Accept: application/json' --header 'authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJuYmYiOjE1NzY1MDY3MzIsImlzcyI6IlpFRURMQUJTIiwicm9sZU5hbWUiOiJtZXJjaGFudCIsImRlYWxlciI6ImJvZGxpbmsiLCJleHAiOjE2MDgwNDIuiidjYTRRTMXMSUwNjczMiwidXNlcklkIjoiSXNhYWN3b3JsZDJyZXZvIn0.NC0x7kxg2-1X6vpPlYCsAFbST1QnZMxk_R9FYta2304" 'https://api.topupbox.com/services/api/v2/w1/balance'
Request URL
https://api.topupbox.com/services/api/v2/w1/balance
Request Headers
{
"Accept": "/",
"authorization": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJuYmYiOjE1NzY1MDY3MzIsImlzcyI6IlpFRURMQUJTIiwicm9sZU5hbWUiOiJtZXJjaGFudCIsImRlYWxlciI6ImJvZGxpbmsiLCJleHAiOjE2MDgwNDIuiidjYTRRTMXMSUwNjczMiwidXNlcklkIjoiSXNhYWN3b3JsZDJyZXZvIn0.NC0x7kxg2-1X6vpPlYCsAFbST1QnZMxk_R9FYta2304"
}
This was what was giving to me from the api documentation, works well in a browser but cannot get it to work in VB.NET.
I can post tables but it's without borders..
curl -X POST "https://eu.yourcircuit.com/rest/v2/webhooks/incoming/randomID" -H "accept: application/json" -H "content-type: application/x-www-form-urlencoded" -d "{ \"text\": \"<table><tr><td>1<\/td><td>2<\/td><\/tr><tr><td>haha<\/td><td>hihi<\/td><\/tr><\/table>\" }"
The table should have a border, but with the parameter border="1" I receive following error:
{"errorDescription":"the request contains invalid
data","validationErrors":["Cannot validate the request parameter with
name ::= [content]","The request parameter with name ::= [content] is
forbidden by ANTISAMY"],"errorCode":"400"}
So how can I fix this? I saw a printscreen form Unify itself where the table has borders..
Tables are not supported in Circuit. For supported formats in Circuit see https://circuitsandbox.net/sdk/classes/Client.html#method_addTextItem.
Having said that, simple tables are currently not blocked by the HTML validator.
The reason your example is not working is because the html is not valid. Use this content with correct opening and closing tags.
curl -X POST "https://eu.yourcircuit.com/rest/v2/webhooks/incoming/randomID" -H "accept: application/json" -H "content-type: application/x-www-form-urlencoded" -d "{ \"text\": \"<table border="1"><tr><td>1</td></tr><tr><td>2</td></tr></table>\" }"
i'll try to get data by following API calling:
Uber API -- POST /requests/estimate
curl -X POST \
-H 'Authorization: Bearer JA.VUNmGAAAAAAAEgASAAAABwAIAAwAAAAAAAAAEgAAAAAAAAG8AAAAFAAAAAAADgAQAAQAAAAIAAwAAAAOAAAAkAAAABwAAAAEAAAAEAAAAHK_p1D73ZBrTyH5MuBCGAhsAAAA28z3l42QLSOiQE_6m1J30O4ZQjwpDR_rVf5o41ONOluUZohTYhXEhHNBCLkDO0mXJV39hE2RkcsIRm9ICi_UMVGESeHsQ_uRsX_yD1EDoUbcdHa0Yhf8XGOJkFz1-IB5x9Ivq6SxHpmREeExDAAAAGRcztTG8GDUTlDYpSQAAABiMGQ4NTgwMy0zOGEwLTQyYjMtODA2ZS03YTRjZjhlMTk2ZWU' \
-H 'Accept-Language: en_US' \
-H 'Content-Type: application/json' \
-d '{
"start_latitude": 37.7752278,
"start_longitude": -122.4197513,
"end_latitude": 37.7773228,
"end_longitude": -122.4272052
}' "https://api.uber.com/v1.2/requests/estimate?scope=request
Response
{"code":"unauthorized","message":"This endpoint requires at least one of the following scopes: profile, request, request.delegate, request.delegate.tos_accept, surge_accept"}%
While Below API are working Fine
/products
/estimates/price
/estimates/time
this is old API. New one looks like this.
GET /v1.2/estimates/price