Note: I also posted this in Stack Overflow. Link here.
I am trying to write a ticket to a Zendesk API from Access/Excel using VBA. I keep receiving the following error:
"error":"Unprocessable Entity","message":"server could not parse JSON"
My code is as follows: (replacing my actual Zendesk domain, username, and token with "zendeskdomain", "username", and "token" respectively).
I was able to take the same JSON string and create a ticket using the actual Zendesk Developer API. I was also able to make a GET connection to work using the same three request headers used in the POST code above.
I feel like I am missing something simple, but I cannot seem to make it work.
Any help would be greatly appreciated.
Thank you
I am trying to write a ticket to a Zendesk API from Access/Excel using VBA. I keep receiving the following error:
"error":"Unprocessable Entity","message":"server could not parse JSON"
My code is as follows: (replacing my actual Zendesk domain, username, and token with "zendeskdomain", "username", and "token" respectively).
VBA Code:
Dim strURL As String, strParse() As String, jsonStr As String
Dim hreq As New MSXML2.XMLHTTP60
Dim tixScript As Object
strURL = "https://zendeskdomain.zendesk.com/api/v2/tickets.json"
hreq.Open "POST", strURL, 0, "username/token", "token"
hreq.setRequestHeader "User-Agent", "Chrome/78.0.3904.108"
hreq.setRequestHeader "Content-Type", "application/json"
hreq.setRequestHeader "Accept", "application/json"
jsonStr = """{""ticket"": {""subject"": ""Testing post requests"", ""requester_id"":393329203772, ""comment"": { ""body"": ""This will work"" }}}"""
hreq.Send jsonStr
MsgBox hreq.responseText
I was able to take the same JSON string and create a ticket using the actual Zendesk Developer API. I was also able to make a GET connection to work using the same three request headers used in the POST code above.
I feel like I am missing something simple, but I cannot seem to make it work.
Any help would be greatly appreciated.
Thank you