I am trying to send a JSON formated request using the VBA-WEB library and am getting the error below:
ERROR – WebHelpers.ParseByFormat: 11000, An error occurred during parsing
10001: Error parsing JSON:
The API I am communicating wants to receive the request formatted as JSON.
I have looked up the error and found it occurs when JSON is not formatted correctly.
I have checked the format of my JSON using multiple online checker and all came back saying my JSON was valid. So the error is coming from something else.
I have found other postings on similar topics but they seem to use: ‘Request.Format = WebFormat.JSON’, where as I am using ‘Request.ContentType = “application/JSON”‘. I have tried both methods and both return the same error.
If someone can see where I may be going wrong that would be much appreciated.
I have attached my code below.
Let me know if there is any additional information I can provide.
Thank you.
Public Sub API()
' CREATING CLIENT
Dim Client As New WebClient
Client.BaseUrl = "https://my_url.com" '
' CREATING REQUEST
Dim Request As New WebRequest
' DEFINING HEADERS
Request.Resource = "/my_extension"
Request.Method = WebMethod.HttpPost
Request.ContentType = "application/json"
'Request.Format = WebFormat.Json
Request.Accept = "application/json"
Request.AddHeader "Authorization", "Bearer XXX"
' REQUEST BODY SCHEMA
Dim Body as New Scripting.Dictionary
' I did not attach the rest of the schema because it is not the issue
Set Request.Body = Body
' CREATE RESPONSE
Dim Response As WebResponse
Set Response = Client.Execute(Request)
' CHECK
Debug.Print Response.Content ' Print out entire response
End Sub
Kyle Atkinson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.