How to send the API body in a MSXML2.XMLHTTP60 patch call

steveotis

New Member
Joined
Jul 11, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
All,
I've successfully used the code below to place some GET API calls to my companies contracted CMS platform.
I'm now trying to do the same for a patch call. See images below, the patch call requires a "BODY" that a GET call does not.
I'm not sure how to put this in my VBA code. I expect it's something like "req.Open(body)" where BODY is some concated string of my body values
but I can't find a solid example to work off of:

This is my POSTMAN call and it works fine:
1689102344460.png


This is what I normally send for a GET request (except "PATCH" is "GET") and it works fine. I now need to know how to put the above body into the code below.
The URL is normally very simple for a get request but I guess the body details cannot be added to the end of the URL.

1689102413175.png
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
The Send method has an optional argument for the request body:

VBA Code:
req.Send ("{""properties"":{...the rest of the request body ...")
Note the use of 2 consecutive double quotes to get 1 double quote within the body string.
 
Upvote 0
Great thank you. This is what I wound up doing and I also seemed to need this line req.setRequestHeader "content-Type", "application/json" or I was getting an error.

1689113063776.png
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,198
Members
452,617
Latest member
Narendra Babu D

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top