0

I'm trying to update fields of a Project server task ("name" for example). My query works fine if I run it as is without batch (I get empty response from server, but the field value changes), but when I add it into a batch it does nothing also returning empty response.

Could you, please, help me to find out what's wrong with my query?

Request without batch that works:

PATCH /pwa/_api/ProjectServer/Projects/GetById('0e3e5db7-ecf2-eb11-911f-001dd8b71c8d')/Draft/Tasks/GetById('005056b6-19d5-1edb-bcdd-9945eea08d54') HTTP/1.1
    Host: <host>
    Accept: application/json
    X-RequestDigest: 0x9CE4CFDF2C5F6E3264993EEBA7C2D5DE1CA4D9E0B0DF175735D6B098E7DEFD04DD0C59F69C28DF7C5EF25A5928D2921F67910279CEEB20DEF18497603F1273A4,12 Aug 2021 09:04:00 -0000
    Content-Type: application/json
    Authorization: Basic cG93ZXJtXHNhcF9jb25uZWN0OlR5aGc4NHVpcA==
    Content-Length: 144
    
    {"odata.metadata":"http://<host>/sites/PWA/_api/$metadata#SP.ApiData.DraftProjects/@Element","odata.type":"PS.DraftTask","Name":"new_name"}

Request in batch that doesn't:

POST /pwa/_api/$batch HTTP/1.1
Host: <host>
X-RequestDigest: 0x9CE4CFDF2C5F6E3264993EEBA7C2D5DE1CA4D9E0B0DF175735D6B098E7DEFD04DD0C59F69C28DF7C5EF25A5928D2921F67910279CEEB20DEF18497603F1273A4,12 Aug 2021 09:04:00 -0000
Content-Type: multipart/mixed; boundary=batch_e3b6819b-13c3-43bb-85b2-24b14122fed1
Authorization: Basic cG93ZXJtXHNhcF9jb25uZWN0OlR5aGc4NHVpcA==
Content-Length: 796

--batch_45473b4e-5ce5-409d-dd5a-3d60082df906
Content-Type: multipart/mixed; boundary="changeset_f9c96a07-641a-4897-90ed-d285d2dbfc2e"
Content-Length: 563
Content-Transfer-Encoding: binary

--changeset_f9c96a07-641a-4897-90ed-d285d2dbfc2e
Content-Type: application/http
Content-Transfer-Encoding: binary

PATCH http://<host>/pwa/_api/ProjectServer/Projects/GetById('0e3e5db7-ecf2-eb11-911f-001dd8b71c8d')/Draft/Tasks/GetById('005056b6-19d5-1edb-bcdd-9945eea08d54') HTTP/1.1
Content-Type: application/json;odata=verbose

{"odata.metadata":"http://<host>/sites/PWA/_api/$metadata#SP.ApiData.DraftProjects/@Element","odata.type":"PS.DraftTask","Name":"new_name"}

--changeset_f9c96a07-641a-4897-90ed-d285d2dbfc2e--

--batch_45473b4e-5ce5-409d-dd5a-3d60082df906--

response:

--batchresponse_708f48ce-0d0a-4097-8bac-607f4c89db0e--

1 Answer 1

1

I've figured it out. The issue was that the biundary in my request differs from the batch number. Still doesn't work though, but now I get response:

--batchresponse_a97eef74-38b3-4c1d-b082-2ac1040e7aac
Content-Type: application/http
Content-Transfer-Encoding: binary

HTTP/1.1 400 Bad Request
CONTENT-TYPE: application/xml;charset=utf-8

<?xml version="1.0" encoding="utf-8"?><m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><m:code>-1, Microsoft.SharePoint.Client.InvalidClientQueryException</m:code><m:message xml:lang="en-US">Invalid request.</m:message></m:error>
--batchresponse_a97eef74-38b3-4c1d-b082-2ac1040e7aac--

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.