Monday, April 15, 2013

POST RAW JSON request with Basic Auth using Chrome Advance REST client

I was wondering how to POST a RAW JSON request with Basic Authentication for Advance REST client. I tried several permutation and combination and finally came up with exact way.



Notes:
1. Somehow single quote did not worked for me.
2. Json in rails way( => ) would work.
3. user = {...} will work on www-form-url-encoded but not with json.

You might be getting JSON parse error even before request reach to controller!

11 comments:

  1. Thank you; I was using single quotes too.

    ReplyDelete
  2. Thanks for your post. I eventually went for XML and needed to have the namespace too.

    ReplyDelete
  3. NIce one..Was trying to post the raw json.. your post helped me.. Thanks (y)

    ReplyDelete
  4. no need to include property name in double quotes
    e.g.
    {
    PropertyName 1: 200 ,
    PropertyName 2:"New"
    }

    ReplyDelete
  5. As I remember I was getting "json parse error" with single quote. I will cross check this.

    ReplyDelete
  6. thanks it worked

    ReplyDelete
  7. How to get this data in controller ? I am sending multiple records then it's give me only last record. So any idea how to get all records ?

    ReplyDelete
  8. How to get this record in controller ? I am doing same like this but I am sending multiple records so in controller it received only one last record. so how to get all records in controller ?

    ReplyDelete
  9. My Rest APi accepts void Test(string id, string i) . I am using advanced rest to send data.
    Here is my payload data
    {
    id:"200" ,
    i:"1"
    }
    But this does not work , I get 500 error

    ReplyDelete
    Replies
    1. "500 error" means you not constructing URL correctly, but send JSON KEYS in double quote:
      { "id": "200" , "i": "1" }

      Please let me know if it does not work!!!

      Delete