Passing a request body in an API call

Good Afternoon,

I’m trying to integrate some get/patch calls to Hubspot in some Excel VBA code. I’ve successfully been able to make some GET’s but my code is incomplete for a PATCH. I’m not sure what to put within this call to pass my body over to HS. I can make it work in POSTMAN but not sure what to put in my VBA code.

The closest I found is I might have to put a req.Send(body)

here and I think ‘body’ needs to be Properties/Subject/“value” all put together but I can’t find a solid example anywhere for the exact format.

Hey, @SMCNULTY :waving_hand: Thanks for the interesting question. There are not any examples that I could find, which seems to match your experience. I have zero direct VBA experience.
I did ask my HubGPT assistant to help and here is an example. Please note, you’ll need to test this and adjust as needed.

Example to test with:

Dim req As New XMLHTTP60, body As String

req.Open "PATCH", "https://api.hubapi.com/your-endpoint", False

body = "{""properties"": {""subject"": ""value""}}"

req.setRequestHeader "Content-Type", "application/json"
req.setRequestHeader "Authorization", "Bearer " & your_access_token

req.Send (body)

I’d love to know how this works, or doesn’t work, for you. It’s helpful for all of us to learn together.

Have fun! — Jaycee

Jaycee,

Thank you for your response. I wound up posting in a EXCEL forum because I thought that might be more applicable than HS. Regardless, below is what I got working; one step closer to integrating some of our Excel tools with Hubspot. It’s essentially what you have suggested. Works good, I’m now able to modify fields in HS via Excel VBA.

It was just the exact format that was tough to find an example of. Double quotes/brackets etc. I was also missing the req.setRequestHeader “content-Type”, “application/json” which was critical.