I have a set of requests to retrieve an object with a GET, manipulate the body and then update the object with a PATCH.
The post-response script in the GET does some of the rote editing, but the user has to do some further editing that I can’t automate before using the PATCH .
I would like to use the post-response script in the GET to pre-set the body of the PATCH so that the user can edit the body manually before sending it.
Is there a way to do that? I can’t find anything in the documentation or elsewhere that looks promising.
Bonus: Is there a way to set the URL of the PATCH from the post-response script of the GET? That would be a real improvement in the operation of these tasks.
(I thought about setting a collection variable and using it in the pre-request script of the PATCH, but that script only executes when the request is sent, and I want to edit it before sending.)
What you’re trying to achieve is quite tricky, given that you’re interacting with APIs directly and not a user interface. Your best bet will be to log the modified response from the GET, copy and paste this into the body of the PATCH, and manually edit it before sending your patch request. Since this includes a manual input from a user, the flow can’t be automated.
To answer your last question around setting the URL of your PATCH request. You can store the URL in a variable, and use that variable in your URL bar. {{baseURL}}/patch
I was afraid that was the case. I had hoped there was a request.OnLoad() or request.OnFocus() kind of event I could use, but I couldn’t find anything, and now I know why.
And thanks for the reminder about using a collection variable for the URL. I do that in other places, but it didn’t occur to me for this application.