This is potentially very basic, but I'm trying to access the JSON under this URL: https://fantasy.premierleague.com/drf/bootstrap-static.
You can see data if you visit the page in a browser but when I use
curl https://fantasy.premierleague.com/drf/bootstrap-static
I get a 200 response but no data (at least that I can see).
Is there something I'm missing? Possibly header related?
Thanks
Looks like it was indeed header related. I needed a "User-Agent"
curl -H "User-Agent: Testing" https://fantasy.premierleague.com/drf/bootstrap-static
worked fine.
In my searching I also discovered you if you go into the network tab of Chrome developer options you can right click the request and copy the curl. Hope this helps someone.
Related
I'm having an architecture that looks like that on AWS, if it matters to the issue:
Lambda function - API Gateway
I'm testing my API with postman by calling my API with a raw body of application/json type.
But in my lambda, the body looks like this
body: '{
\n\t"name": "Coinche",
\n\t"description": "Un jeu intéressant à plusieurs",
\n\t"rules": "Gagner",
\n\t"origin": "France"\n
}'
which gives me an error, obviously.
So what's the catch here? Doesn't the application/json takes care of sending a json? Should I translate the string back to json inside lambda function?
You may require to add Content-Type: application/json on API Gateway Integration Request body template mapping like this:
This is not exactly an answer to the question, but for me, none of this resolved the issues of getting \n\t added to my JSON. JSON.parse and JSON.stringify all failed with this and I could not get past the errors being thrown.
I switched from using Postman to Insomnia and problem went away. I also noticed it uses end-to-end encryption so I'm not trying to bother with variables in the same way for my keys etc..
I just have a JSON file with all my variables to re-use in Insomnia. Works pretty nicely so far.
I'm not trying to sell anything here, it is just that it took me a while to even figure out what was going on and that the issue was coming from Postman, so it seemed worth sharing.
I had the exact same experience but in a different environment.
Under the same server program from desktop windows 10 and mac, postman with windows 10 worked and the one with mac didn't work like yours.
The key "Content-Type" in Headers (refer to the below image) were both unchecked, but once I checked it on mac, it just became normal.
postman menu
I'm struggling with creating POST multipart/mixed request with Postman Chrome extension
Here is my curl request what works nice
curl -H "Content-Type: multipart/mixed"
-F "metadata=#simple_json.json; type=application/json "
-F "content=#1.jpg; type=image/jpg" -X POST http://my/api/item -i -v
interesting part of response
Content-Length: 41557
Expect: 100-continue
Content-Type: multipart/mixed; boundary=----------------------------8aaca457e117
additional stuff not fine transfer.c:1037: 0 0
HTTP 1.1 or later with persistent connection, pipelining supported
And when I use Postman
I getting such response
{"message":"Could not parse multipart servlet request;
nested exception is org.apache.commons.fileupload.FileUploadException:
the request was rejected because no multipart boundary was
found","type":"error","status":500,"requestId":"1861eloo6fpio"}
That's it - I wish to get rid of that error.
If some more information needed please ask :)
I was facing this problem too. Short answer: remove the Content-Type header from your Postman request.
The long story is that the Content-Type for a multipart request should be rather special -- it should look kind of like this:
multipart/form-data; boundary=----WebKitFormBoundaryzeZR8KqAYJyI2jPL
The problem is that the boundary is important and it needs to exactly match the boundary used to separate the files being uploaded. The solution is simple: do not specify a Content-Type! When you upload files, Postman will automatically append the above content type for you, except the boundary will be filled in with whatever Postman or Chrome is using to separate the multipart content.
You can verify this behavior by using Chrome developer tools (within Postman) to examine the Content-Type header being added, in addition to the Content-Disposition headers of the multipart data, which are also a pain to construct manually (and impossible within Postman).
Note: My answer is a solution for those who need a multipart/form-data answer. The OP was looking for a multipart/mixed solution. My answer will not suffice in this scenario. That being said, it seems a lot of people just want the multipart/form-data solution, so I will leave my answer here.
Left this comment on: https://github.com/postmanlabs/postman-app-support/issues/1104
Ninja update: Not sure if this will help anyone else but there is a workaround for a specific scenario where you have multiple file types / content types being uploaded in a single multipart POST request.
Set the Header Content-Type to multipart/mixed.
Select the form-data option in Body.
Convert all of your items into files. String content should become a text file, etc.
Add each file by selecting file, adding a key name.
This approach doesn't require actually manually specifying each Content-Type or Content-Disposition. The trick here was to serialize all relevant content into a persistent file type. You can ignore the "convert it into a file" step if it's text :) Hope that helps someone!
I have been given a url .. www.abc.com/details and asked to send my name and phone number on this url using POST. They have told me to set the content-type as application/json and the body as valid JSON with the following keys:
name: name of the user
phone number: phone number of the user
Now i have no clue how to send this request! Will it be something like:
http://www.abc.com/details?method=post&name=john&phonenumber=445566
or do i have to use java to send the same?
Please help
Based on what you provided, it is pretty simple for what you need to do and you even have a number of ways to go about doing it. You'll need something that'll let you post a body with your request. Almost any programming language can do this as well as command line tools like cURL.
Once you have your tool decided, you'll need to create your JSON body and submit it to the server.
An example using cURL would be (all in one line, minus the \ at the end of the first line):
curl -v -H "Content-Type: application/json" -X POST \
-d '{"name":"your name","phonenumber":"111-111"}' http://www.example.com/details
The above command will create a request that should look like the following:
POST /details HTTP/1.1
Host: www.example.com
Content-Type: application/json
Content-Length: 44
{"name":"your name","phonenumber":"111-111"}
You can post data to a url with JavaScript & Jquery something like that:
$.post("www.abc.com/details", {
json_string: JSON.stringify({name:"John", phone number:"+410000000"})
});
It is not possible to send POST parameters in the URL in a straightforward manner. POST request in itself means sending information in the body.
I found a fairly simple way to do this. Use Postman by Google, which allows you to specify the content-type (a header field) as application/json and then provide name-value pairs as parameters.
You can find clear directions at [2020-09-04: broken link - see comment] http://docs.brightcove.com/en/video-cloud/player-management/guides/postman.html
Just use your URL in the place of theirs.
You can use postman.
Where select Post as method.
and In Request Body send JSON Object.
In windows this command does not work for me..I have tried the following command and it works..using this command I created session in couchdb sync gate way for the specific user...
curl -v -H "Content-Type: application/json" -X POST -d "{ \"name\": \"abc\",\"password\": \"abc123\" }" http://localhost:4984/todo/_session
If you are sending a request through url from browser(like consuming webservice) without using html pages by default it will be GET because GET has/needs no body. if you want to make url as POST you need html/jsp pages and you have to mention in form tag as "method=post" beacause post will have body and data will be transferred in that body for security reasons. So you need a medium (like html page) to make a POST request. You cannot make an URL as POST manually unless you specify it as POST through some medium. For example in URL (http://example.com/details?name=john&phonenumber=445566)you have attached data(name, phone number) so server will identify it as a GET data because server is receiving data is through URL but not inside a request body
In Java you can use GET which shows requested data on URL.But POST method cannot , because POST has body but GET donot have body.
I'm trying to replicate a request I make on a website (ie zoominfo.com) using the same http POST parameters using chrome rest console, but it fails for some reason. I'm not sure if there is a missing field or it's not working because the origin of the request isn't valid.. can someone point me out in the right direction? Below is a detailed explanation of the experiment:
ORIGINAL CASE
basically if I go to zoominfo.com (registered and all) I see a form page that I need to fill:
if I hit enter.. the site makes an ajax call. If I open the chrome web dev tools, and open the network tab, I see the details of the ajax call:
notice the body of the POST has the name John Becker in it:
{"boardMember":{"value":"Include","isUsed":true},"workHistory":{"value":"CurrentAndPast","isUsed":true},"includePartialProfiles":{"value":true,"isUsed":true},"personName":{"value":"john%20becker","isUsed":true},"lastUpdated":{"value":0,"isUsed":true}}
the response is shown under the respones tag:
WHAT I'M TRYING TO DO
basically replicate what i've done above using a REST console (note: so there is nothing illegal here.. i'm just replacing a chrome browser action with a rest client action.. i'm not hacking anyone and i'm not getting information I can't get the normal way, but if someone feels otherwise.. please let me know)..
so I plug in the same parameters as above into the rest console:
now i'm not sure about authentication.. but just to be safe, i entered the same user name and pwd i have for the site into the REST console:
but then I keep on getting an error as a response to my rest console's request:
UPDATE: CORRECT ANSWER:
so according to JMTyler's answer.. I had to simply include criteria in the RAW body, and convert it to url encoding.. in addition to that, I had to explicitly set the encoding in the rest console body..
looking at the chrome inspector more closely, it turns out that I simply had to click on view source:
to get the url-encoded value that I needed to put in the RAW body in the rest console:
I also had to set encoding to gzip,deflate,sdch and things worked fine!
The form is posting all that JSON under the field criteria. You can see this in the screencap of the chrome dev console you posted.
Just start your raw body in rest console with criteria= and make sure the json has been url-encoded. That should do it.
No authentication is needed because none is passed through the headers in your screencap. Any cookies you have when you load the page normally will also be loaded through rest console, so you don't need to worry about explicitly setting them.
Reading your problems I'll make an educated guess:
zoominfo does not provide an RESTful API.
Rest-Console understands and uses HTTP Authentication, which is different from the authentication handler zoominfo implemented.
A possible way to work around may be:
Make a call to the login-page via rest console. you'll get back cookies and a lot more.
In subsequent requests to zoominfo be sure to include those cookies (likely holding some session information) in your request, therefore acting like a browser.
I am trying to inspect some html, which is not displayed correctly in IE. when I look at the html in IE and FF, they are both different slightly and this might be causing the issue.
I want to grab html returned from the server and thus do not want to send request using a browser.
can anyone advise me any such tool ??
If you are using linux or unix system, you can use curl to do that.
to send GET request:
curl "<< request-url >>"
to send POST request:
curl --data "<< post-parameter >>" "<< request-url >>"
And you can use -X option to define what HTTP method you want to send with.
or maybe you're using Windows, you can use the web tool to send GET/POST requests like
http://hurl.it/
curl would do the trick. curl http://www.google.com, for example.