I have a 3rd party REST, which I am successfully able to call like this using CURL (shell). This API return JSON. I tried calling same API, by changing content type to application/x-www-form-urlencoded but it doesn't work. I think I am forced to use content-type: multipart/form-data
curl --request POST --url https://************************* --header 'Authorization: Bearer ********' --header 'content-type: multipart/form-data; ' --form cluster_id=0717-035521-puny598 --form start_time=1534357800000 --form end_time=1534444199999 --form order=ASC --form limit=500
Now I want to call same API using InvokeHTTP processor (NiFi). So I configured it as follows. But I am not able to do a successful call. (it is not a proxy issue).
Following is how I am creating POST body (by FF)
I have tried replacing "enter" by \r\n etc, or changing body as name1=val1&name2=val2&.... etc. nothing worked.
This is the response I am getting.
[
I am able to run CURL (shell, from same server where Nifi is running). Also I am able to access url via postman.
[
finally, it worked. flow is somewhat like this.
GenerateFlowFile->UpdateAttribute->AttributesToJSON->InvokeHTTP
Only change, I made to InvokeHTTP. reverted content-type back to ${mime.type}.
I was struggling with this for a few hours. I've got a backend API that has
ResponseEntity<ByteArrayResource> post (#RequestPart("file") MultipartFile file) and a NiFi processor that sends XLSX data to this. I was getting the same issue... The key for me were the bottom two properties:
FlowFile Form Data Name -> file (this is the name of the variable in the API call)
Set Flowfile Form Data File Name -> true
Related
I am trying to embed OAuth 2.0 grant_type password access token to my insomnia client API calls but getting "Failed to fetch token url= state us=0"
When we try below curl command its returning the access token. each time we have to copy access token and add it as header in insomnia rest call (Their is no client secret as it not confidential).
curl --request POST \
--url https://mydomain/auth/realms/my-app/protocol/openid-connect/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data client_id=myclientid \
--data username=app.admin \
--data 'password=password!' \
--data grant_type=password
Above curl if you create in insomnia client as POST request that is also working only thing is we need to copy and paste as header in other API calls
NOTE: the same is working in postman rest client through pre-request script but I want it to be achieved in insomnia client
After doing lot of research found out the solution by myself
follow this blog https://www.ankursheel.com/blog/automatically-set-access-token-authenticated-requests-insomnia
You need to create separate Generate token request, and set the bearer token in the API request where you want to embed Auth token automatically, click on the Bearer tab and enter Response ⇒ Body Attribute for the token and follow those instruction it worked for me :)
I'm trying to use SuiteQL to query a workbook for a client implementation, but I'm having trouble getting it to work in VS Code. I downloaded the Postman environment template and collections archive from the SuiteTalk tools download page and then sent a test request. It returned a successful JSON response. I then tried to send the same sample request using cURL in the VS Code terminal, then with node-fetch, and then using an npm library called netsuite-rest. All of these return 401 'INVALID_LOGIN'. Why does it work when I use Postman, but nowhere else? Here's a sample of my cURL request:
curl --location --request POST 'https://<ACCOUNT_ID>.suitetalk.api.netsuite.com/services/rest/query/v1/suiteql?limit=5' \
--header 'prefer: transient' \
--header 'Content-Type: application/json' \
--header 'Authorization: OAuth realm="<ACCOUNT_ID>",oauth_consumer_key="<CONSUMER_KEY>",oauth_token="<TOKEN>",oauth_signature_method="HMAC-SHA256",oauth_timestamp="<TIMESTAMP>",oauth_nonce="<NONCE>",oauth_version="1.0",oauth_signature="<SIGNATURE>"' \
--header 'Cookie: NS_ROUTING_VERSION=LAGGING' \
--data-raw '{
"q": "SELECT id, companyName, email, dateCreated FROM customer WHERE dateCreated >= '\''01/01/2019'\'' AND dateCreated < '\''01/01/2020'\''"
}'
I see this is an old thread however, I myself am just getting started with NetSuite and Postman. For me, the netsuite Postman query will work fine when you get your access token and this will work for a short period of time. Eventually it will fail and at that time you need to use your refresh token to get a new access token. Then, add the fresh access token into your query authorization as a bearer token - and then the query will start working again.
Once it is actively working then there is a magic Area of postman = Code Snippet. So click on that and then notice that there is a pulldown menu of many code bases - that will display the entire code request for your query! For example you could choose nodeJS - Axios - and just copy the code and paste it in to your webpage.
The one thing you will have to remember is that the access token Will expire after a period of time and then you will have to replace the access token with a fresh one (using the refresh token).
Laravel 5.2 docs state:
AJAX Requests & Validation
In this example, we used a traditional form to send data to the
application. However, many applications use AJAX requests. When using
the validate method during an AJAX request, Laravel will not generate
a redirect response. Instead, Laravel generates a JSON response
containing all of the validation errors. This JSON response will be
sent with a 422 HTTP status code.
Src: https://laravel.com/docs/5.2/validation#quick-ajax-requests-and-validation
However, this doesn't seem correct. A simple CURL call to a route using validation, still returns HTML/a redirect:
curl -X POST -H "Content-Type: application/json"
-H "Cache-Control: no-cache"
-d '{}' "http://yours.com/user/register"
The response of the above is HTML, and a redirect. It's not JSON.
Even this page: https://laravel.com/docs/5.2/requests#retrieving-input states:
Retrieving JSON Input Values
When sending JSON requests to your application, you may access the
JSON data via the input method as long as the Content-Type header of
the request is properly set to application/json.
So what have we missed? What is the solution?
You also seem to need the following header:
"X-Requested-With: XMLHttpRequest"
Thus:
curl -X POST -H "Content-Type: application/json"
-H "X-Requested-With: XMLHttpRequest"
-H "Cache-Control: no-cache"
-d '{}' "http://yours.com/user/register"
And now $this->validate(...) is properly returning a JSON response.
I am new to Spring and very new to Spring Oauth2 Security. I have searched a lot about how to request the following link in web browser(In Firefox Rest Client plugin).The following request is curl and working perfectly fine in terminal through this command.
I am getting the problem while giving basic authorization. So How we can interact with basic authorization given below as -vu myapp:123456.
curl -X POST -vu myapp:123456 http://localhost:8080/oauth/token -H "Accept: application/json" -d "password=sunit&username=sunit&grant_type=password&scope=read%20write&client_secret=123456&client_id=myapp"
I used wireshark for capture the request and ended the same request to fb just to connect because I don't have a local server running... you can see that is a post request with the body in encoded URL...
This is a regular funded account - It will insist there is no From Number - I also tried as request parameters rather than request body, SID and TOKEN are correct, tested by modifying them and getting appropriate error. Works fine with the twilio libraries, not as a standalone POST
POST /2010-04-01/Accounts/ACCOUNT_SID/Messages.json HTTP/1.1
Host: ACCOUNT_SID:AUTH_TOKEN#api.twilio.com
Content-Type: text/json
Cache-Control: no-cache
{ "body": "Jenny please?! I love you <3", "From": VALID_TWILIO_NUMBER, "to": MY_CELL }
Also I would like to specify the ACCOUNT_SID and AUTH_TOKEN as header parameters, but Twilio does not recognize them.
The following works (from POSTMAN history)
POST /2010-04-01/Accounts/ACCOUND_SID/Messages.json HTTP/1.1
Host: api.twilio.com
Authorization: Basic Base64_encoding(ACCOUNT_SID:AUTH_TOKEN)
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
Body=%22Test+1+-+urlencoded%22&From=%22%2BVALID_TWILIO_NUMBER%22&To=%22%2BMY_CELL%22
A few observations:
This worked using POSTMAN in Chrome and HTTPRequester in Firefox (Authorization entered interactively through user/passwd dialog)
The Body, From, and To parameters MUST be spelled that way, if the first letter is lowercase, it will return the above error or similar.
That was the only Content-Type that worked - could not get it to work with a JSON request body (the way I posed it on the original question) - that remains an open issue.
I suggest that you use request parameters:
$ curl -XPOST https://api.twilio.com/2010-04-01/Accounts/AC5ef8732a3c49700934481addd5ce1659/Messages.json \
-d "Body=Jenny%20please%3F%21%20I%20love%20you%20<3" \
-d "To=%2B15558675309" \
-d "From=%2B14158141829" \
-d "MediaUrl=http://www.example.com/hearts.png" \
-u 'AC5ef8732a3c49700934481addd5ce1659:{AuthToken}'
Additionally, I have seen that "No From Parameter" error when the phone number is not properly formatted.
I was trying to do this with Twilio's new WhatsApp messaging and was running into the same issue. Content-type was important, but also how the body of the POST request was formatted.
From=whatsapp:%2B441618507453&To=whatsapp:%2B17796758684&Body=Your appointment is coming up on {{July 21}} at {{3PM}}
Note the use of URL encoding for "+" symbols