Curl HTTP Post VB.NET - vb.net

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.

Related

curl, API request works in Insomnia, but not in generated code for curl

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

USER.SUBMIT_FORM_DATA: Event filter Fails for UPDATE Outgoing WebHook call

I can register events with USER.SUBMIT_FORM_DATA no problem, also I can Update (PUT) all the other event filters without errors. USER.SUBMIT_FORM_DATA fails when using PUT to update. Reproduced error in PowerShell, Curl and Postman. I also noticed Swagger does not have USER.SUBMIT_FORM_DATA available in the array. This is what's available:
CONVERSATION.CREATE
CONVERSATION.UPDATE
CONVERSATION.ADD_ITEM
CONVERSATION.UPDATE_ITEM
USER.USER_UPDATED
USER.USER_SETTING_UPDATED
Request:
curl -L -X PUT 'https://circuitsandbox.net/rest/v2/webhooks/IdHere' \
-H 'accept: application/json' \
-H 'authorization: Bearer Token\
-H 'content-type: application/x-www-form-urlencoded' \
--data-urlencode 'url=https://webhook.site/IdHere' \
--data-urlencode 'filter=USER.SUBMIT_FORM_DATA'
Error:
{
"errorDescription": "the request contains invalid data",
"validationErrors": [
"The request array with name ::= [filter] and content value ::=[USER.SUBMIT_FORM_DATA]does not match the expression ::= [CONVERSATION.CREATE||CONVERSATION.UPDATE||CONVERSATION.ADD_ITEM||CONVERSATION.UPDATE_ITEM||USER.USER_UPDATED||USER.USER_SETTING_UPDATED]."
],
"errorCode": "400"
}
Sorry, that is a bug in the endpoint, I added a fix which will be available with the next release.

Uber API "POST /requests/estimate" response POST "code":"unauthorized"

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

How to create custom user using the REST API?

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'.

How to change --header 'Accept: application/json' to --header 'Accept: application/xml'

WSO2 API manger how to change --header 'Accept: application/json' to --header 'Accept: application/xml'?
I have added some APIs to WSO2 API Publisher. I can connect via API Console for some API but some failed. I noticed the one failing due to --header Accept: application/json'- all other which connected successfully has --header 'Accept: application/xml.
Also it keep return Response Code 0 with Response Headers:
"error": "no response from server"
I have tried to update this but still the same: /opt/wso2am-2.1.0/repository/deployment/server/synapse-configs/default/sequences/_auth_failure_handler_.xml
Please advise.
In the publisher where you define the resources for your API, you can specify the "Produces" field (set it to application/xml), that should be used as the default value from the API Store test console.
Regardless that - the client could post any Accept header in the request. The "Produces" field is only an indication, it doesn't enforce the header value.
I suggest you test the calls anyway using the curl (SoapUI, Postman or any other feasible tool) so you can see what the service REALLY returns. The "Response Code 0" message usually means some error response (400, 500, .. anything) it's just not necessarily shown in the DEV console.
Have fun