How do I POST JSON data with cURL?

You need to set your content-type to application/json. But -d (or –data) sends the Content-Type application/x-www-form-urlencoded, which is not accepted on Spring’s side. Looking at the curl man page, I think you can use -H (or –header): Full example: (-H is short for –header, -d for –data) Note that -request POST is optional if you … Read more

Use of PUT vs PATCH methods in REST API real life scenarios

NOTE: When I first spent time reading about REST, idempotence was a confusing concept to try to get right. I still didn’t get it quite right in my original answer, as further comments (and Jason Hoetger’s answer) have shown. For a while, I have resisted updating this answer extensively, to avoid effectively plagiarizing Jason, but … Read more

How do I POST JSON data with cURL?

You need to set your content-type to application/json. But -d (or –data) sends the Content-Type application/x-www-form-urlencoded, which is not accepted on Spring’s side. Looking at the curl man page, I think you can use -H (or –header): Full example: (-H is short for –header, -d for –data) Note that -request POST is optional if you use -d, as the -d flag implies a POST request. On Windows, things are slightly different. See the comment thread.

“SyntaxError: Unexpected token < in JSON at position 0"

The wording of the error message corresponds to what you get from Google Chrome when you run JSON.parse(‘<…’). I know you said the server is setting Content-Type:application/json, but I am led to believe the response body is actually HTML. Feed.js:94 undefined “parsererror” “SyntaxError: Unexpected token < in JSON at position 0” with the line console.error(this.props.url, status, err.toString()) underlined. The err was actually thrown … Read more

Grabbing the current viewer count for youtube live streaming

UPDATE 2: YouTube has unfortunately dropped support for this method. Hopefully there will be a new solution in the future without using their API (since it has quote limits). Try this link: https://www.youtube.com/live_stats?v={videoid} Find a Live event on YouTube and replace the video id in the link. This should retrieve the number of concurrent views for that … Read more

“SyntaxError: Unexpected token < in JSON at position 0"

The wording of the error message corresponds to what you get from Google Chrome when you run JSON.parse(‘<…’). I know you said the server is setting Content-Type:application/json, but I am led to believe the response body is actually HTML. Feed.js:94 undefined “parsererror” “SyntaxError: Unexpected token < in JSON at position 0” with the line console.error(this.props.url, … Read more