0

I'm working on an SPFx webpart to do some interactions with Project Server. As part of this, I need to delete some tasks.

I have a function that deletes tasks using HttpClient.fetch() with a DELETE verb sent to

https://<sitecollection>/<site>/_api/ProjectServer/Projects('projectid')/Draft/Tasks('taskid')

as per this documentation.

My function returns a Promise that resolves to an array of HttpClientResponse objects (one per delete request), so after I call my delete function, I chain

.then((responses: HttpClientResponse[]) => {
    responses.forEach((response: HttpClientResponse) => {
        response.json().then(deleteJSON => {
            console.log(deleteJSON);
        });
    });
});

because I want to see if there is some sort of verification object that has the task ID of the task that was just deleted, so I can verify which tasks were successfully deleted, and which might have failed.

Just before resolving the Promise I log to the console the HttpClientResponse[] that is about to be resolved. I can see that they were all 200/OK, ~~which means the DELETEs worked,~~ but then when it gets to response.json(), I get the

Syntax Error: unexpected end of JSON input

error.

Should I be expecting something to be returned from a DELETE? Is that a bug, or is that just because nothing is actually sent back from the server after a DELETE?

If it makes a difference, in the HttpClientResponses, bodyUsed is true and body is a ReadableStream.


Hmm, well, since the responses were all 200/OK I thought the DELETEs worked, but going back and checking, it seems apparently not. I guess that will be for another question...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.