jere
jere

Reputation: 4304

What's wrong with this OData batch update query?

I followed the example from here but I cannot get this to work!

I can't see anything wrong with the update query and I can't think of what to change because it seems fine. I'm only testing with one request because I wanted to make sure it works first.

Here's the request's body:

--batch_hJUuHcmH7ADWhYbtkF0o9JWlq
Content-Type: multipart/mixed; boundary=changeset_oYIVi6ByvAtKBlI7hqFWoOwX7

--changeset(oYIVi6ByvAtKBlI7hqFWoOwX7)
Content-Type: application/http
Content-Transfer-Encoding: binary

MERGE PrescriptionService.svc/Prescriptions(1L) HTTP/1.1
Host: 192.168.10.179
Content-Type: application/json;odata=verbose

{"PrescriptionType":"RegularMedicationPrescriptionType","Page":"0","Comment":"whoaaaaaa"}

--changeset(oYIVi6ByvAtKBlI7hqFWoOwX7)--
--batch(hJUuHcmH7ADWhYbtkF0o9JWlq)--

I get a 202 Accepted so the "overall" batch request is not malformed. This is the response from the server:

--batchresponse_d8e813eb-0327-4518-9312-9b7a55d0da0c

Content-Type: multipart/mixed; boundary=changesetresponse_fc085e3b-68a8-46dd-86c6-334b1070607d



--changesetresponse_fc085e3b-68a8-46dd-86c6-334b1070607d--

--batchresponse_d8e813eb-0327-4518-9312-9b7a55d0da0c--

I tried POSTing to that same URL in the batch body to create an entity and it doesn't work either, so it has to be something with the request body.

What's wrong with the request's body?

Upvotes: 0

Views: 1220

Answers (1)

Vitek Karas MSFT
Vitek Karas MSFT

Reputation: 13320

The changeset boundary as specified in the header:

boundary=changeset_oYIVi6ByvAtKBlI7hqFWoOwX7

must match exactly the one used later on:

--changeset(oYIVi6ByvAtKBlI7hqFWoOwX7)

Which it doesn't. I don't know why you added the parenthesis, but they should not be there. Same goes for the batch boundary itself.

Upvotes: 1

Related Questions