0

这是开发人员运行代码时我们可以在提琴手中看到的 JSON

{
    "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
}

在此我们有"Type":{"Id":7,"Name":"Conference"}一个名称和 ID 对。我们编写了以下代码来发送请求。

$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\"}");

但是,我收到“选择有效类型”错误。

知道为什么会这样吗?

4

1 回答 1

1

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

于 2014-11-25T08:56:31.417 回答