Posting a File and Associated Data to a RESTful WebService preferably as JSON

This is probably going to be a stupid question but I’m having one of those nights. In an application I am developing RESTful API and we want the client to send data as JSON. Part of this application requires the client to upload a file (usually an image) as well as information about the image. … Read more

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

First of all, some definitions: PUT is defined in Section 9.6 RFC 2616: The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing on the origin server. If … Read more

Parsing JSON with Unix tools

I’m trying to parse JSON returned from a curl request, like so: curl ‘http://twitter.com/users/username.json’ | sed -e ‘s/[{}]/”/g’ | awk -v k=”text” ‘{n=split($0,a,”,”); for (i=1; i<=n; i++) print a[i]}’ The above splits the JSON into fields, for example: % … “geo_enabled”:false “friends_count”:245 “profile_text_color”:”000000″ “status”:”in_reply_to_screen_name”:null “source”:”web” “truncated”:false “text”:”My status” “favorited”:false % … How do I print … Read more

How to reformat JSON in Notepad++?

I need Notepad++ to take a json string from this {“menu”: {“id”: “file”,”value”: “File”,”popup”: {“menuitem”: [{“value”: “New”, “onclick”: “CreateNewDoc()”},{“value”: “Open”, “onclick”: “OpenDoc()”},{“value”: “Close”, “onclick”: “CloseDoc()”}]}}} to this… {“menu”: { “id”: “file”, “value”: “File”, “popup”: { “menuitem”: [ {“value”: “New”, “onclick”: “CreateNewDoc()”}, {“value”: “Open”, “onclick”: “OpenDoc()”}, {“value”: “Close”, “onclick”: “CloseDoc()”} ] } }} I looked around … Read more

How do I get ASP.NET Web API to return JSON instead of XML using Chrome?

This question’s answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions. Using the newer ASP.NET Web API, in Chrome I am seeing XML – how can I change it to request JSON so I can view it in the browser? I do believe … Read more

How do I POST JSON data with cURL?

I use Ubuntu and installed cURL on it. I want to test my Spring REST application with cURL. I wrote my POST code at the Java side. However, I want to test it with cURL. I am trying to post a JSON data. Example data is like this: {“value”:”30″,”type”:”Tip 3″,”targetModule”:”Target 3″,”configurationGroup”:null,”name”:”Configuration Deneme 3″,”description”:null,”identity”:”Configuration Deneme 3″,”version”:0,”systemId”:3,”active”:true} … Read more

What is the correct JSON content type?

I’ve been messing around with JSON for some time, just pushing it out as text and it hasn’t hurt anybody (that I know of), but I’d like to start doing things properly. I have seen so many purported “standards” for the JSON content type: application/json application/x-javascript text/javascript text/x-javascript text/x-json But which one is correct, or … Read more