简体   繁体   中英

WebApi request through Sahi is giving error. What could be the cause?

Here is JSON that we can see in fiddler when developer is running his code

{
    "EventId": 0,
    "Title": "Matz test event",
    "Topics": "203,207",
    "Type": {
        "Id": 7,
        "Name": "Conference"
    },
    "Notes": "Test Meeting Notes",
    "StartDate": "03 March 2014, 05:00 PM",
    "EndDate": "03 March 2014, 06:00 PM",
    "Venue": "Venue 1",
    "Address": "ub Plaza , st Marks Road, bangalore ,India",
    "Address1": "Ub Plaza",
    "Address2": "St Marks Road",
    "City": "Bangalore",
    "State": "",
    "Country": "India",
    "Latitude": "12.9716396",
    "Longitude": "77.6010666",
    "Contactids": "0~0",
    "OcmContactIds": "61756~52122",
    "LastNames": "Andrews~Andrews",
    "FirstNames": "Alyse~Benjamin",
    "MiddleNames": "G.~",
    "FirmIds": "MRGNSTOO4~WNGRSS001",
    "FirmNames": "Morgan Stanley & Co. LLC~Columbia Wanger Asset Management,LLC",
    "RsvpIds": "3~2",
    "AttendanceIds": "1~0",
    "ContactNotes": "~",
    "TopicIds": "203~207",
    "CoprPartIds": "87~47",
    "CorpBrokerId": 8
}

In this we have "Type":{"Id":7,"Name":"Conference"} , a name and id pair. We wrote the below code to send the request.

$request.setBody("{\"Title\":\"Matz test event Updated\",\"Type\":[{\"Id\":7,\"Name\":\"Conference\"}],\"StartDate\":\"03 March 2014, 06:00 PM\",\"EndDate\":\"03 March 2014, 07:00 PM\"}");

However, I am getting "Select a valid Type" error.

Any idea why is this happening like this?

如果您具有JSON,则可以使用stringify()并将字符串传递给$ request.setBody。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM