locked
Is there a way to change batch response body elements to JSON? RRS feed

  • Question

  • Hi, I'm sending some operations in batch to my dataservice and using http://code.msdn.microsoft.com/DataServicesJSONP to get JSON responses but the elements in my batch response body are always in Atom format.
    Is there a way to force responses and errors for batch operations to JSON. A simple solution would be to force all responses to that format, I'm not using Atom at all. 

    Regards.

    Monday, September 20, 2010 7:01 AM

Answers

  • Hi,

    The format of each part of the batch response is driven by the respective request part's Accept header. For this to work each part of the request batch must specify the Accept header as application/json. So make sure that's the case when you construct the request payload.

    Thanks,


    Vitek Karas [MSFT]
    Monday, September 20, 2010 8:04 PM
    Moderator

All replies

  • Hi,

    The format of each part of the batch response is driven by the respective request part's Accept header. For this to work each part of the request batch must specify the Accept header as application/json. So make sure that's the case when you construct the request payload.

    Thanks,


    Vitek Karas [MSFT]
    Monday, September 20, 2010 8:04 PM
    Moderator
  • Sorry for my late response. It worked as you said.
    Is there any way to get JSON errors too?

    Thanks.

    Wednesday, September 22, 2010 5:49 AM
  • If the request specified Accept: application/json then the response should be JSON, even if it's an error response. Do you see any other behavior?

    Thanks,


    Vitek Karas [MSFT]
    Wednesday, September 22, 2010 6:01 AM
    Moderator
  • I'm receiving XML errors even if I receive JSON responses on success.

    Wednesday, September 22, 2010 6:05 AM
  • Could you please post a network trace of that occuring? (use fiddler or something similar).

    Thanks,


    Vitek Karas [MSFT]
    Wednesday, September 22, 2010 6:06 AM
    Moderator