locked
Post operation using Json as payload not working in WCF Data Service? RRS feed

  • Question

  • Hello,

    I have created WCF Data Service using Entity Framework. All by default CRUD operations using 'atom+xml' works. But if  I try to do the same with Json its not working. Ihave also used [JSONPSupportBehavior] but still it gives same error 400: Bad request.

    How do I post and Put json payload on WCF data Service?

    Monday, June 20, 2016 3:15 PM

All replies

  • Ihave also used [JSONPSupportBehavior] but still it gives same error 400: Bad request.

    How do I post and Put json payload on WCF data Service?

    Well first you have to figure out why you are getting the 400 error, which means that the URL pointing to the service is wrong  usually  due to bad parms being passed on the URL that is pointing to the Web service method, and the site can't found that the URL is pointing to with  bad information in the URL..

    I would suggest that you use Fiddler (free) and look at the raw data being passed on the URL at the time you get the 400 error code and see what is wrong with the URL and parms being passed.

    Monday, June 20, 2016 8:09 PM
  • Below is the raw data. Does WCF allow to post json data?

    POST http://localhost:60022/ElogbookService.svc/BYPASSes HTTP/1.1
    Content-Type: application/json
    Accept: application/json
    Host: localhost:60022
    Content-Length: 199

    {
    "LOGNO": 7012
    "BYPASSNAME": ""
    "DATE": ""
    "UNIT": 99
    "STATUS": ""
    "TIME": ""
    "LOCATIONID": 1
    "CREATED_DATE": ""
    "UPDATED_DATE": ""
    "CREATED_BY": ""
    "UPDATED_BY": ""
    "DESCRIPTION": ""
    }

    Tuesday, June 21, 2016 5:32 AM
  • Below is the raw data. Does WCF allow to post json data?

    http://wcftutorial.net/How_To_JSON_Using_WCF.aspx

    It's not that can WCF accept Json data is the problem, because it can.

    You either use WCF or you can go Web API with Web API being Json based out the gate.

    The issue is why are you getting the error code 400 site not found, which has been explained to you and you need to use Fiddler that can possibly show you why you are getting the 400.

    I also suggest that you post to the below forum.

    https://social.msdn.microsoft.com/Forums/en-US/home?forum=adodotnetdataservices

    Tuesday, June 21, 2016 10:52 AM