I have the following JSON POST sample code which I am trying to convert to VBA for Excel:
POST /services/shipper/orders HTTP/1.1
Content-Type: application/json
User-Agent: Mozilla 5.0
Host: qa.etowertech.com
X-WallTech-Date: Tue, 06 Jan 2018 21:20:27 GMT
Authorization: WallTech test5AdbzO5OEeOpvgAVXUFE0A:79db9e5OEeOpvgAVXUFWSD
Here is the code I came up with:
With JsonHTTP
.Open "POST", "http://qa.towertech.com/services/shipper/orders", False
.setRequestHeader "RequestName", "application/json"
.setRequestHeader "Accept", "application/json"
.setRequestHeader "User-Agent", "Mozilla 5.0"
.setRequestHeader "Host", "qa.etowertech.com"
.setRequestHeader "X-WallTech-Date", "Tue, 06 Jan 2018 21:20:27 GMT"
.setRequestHeader "Authorization", "WallTech test5AdbzO5OEeOpvgAVXUFE0A:79db9e5OEeOpvgAVXUFWSD"
.send (body)
End With
I wasn't sure where the POST /services/shipper/orders HTTP/1.1
input should go
I keep getting this response:
{
"status": "Failed",
"errors": [
{
"code": 100004,
"message": "System internal error"
}
],
"data": null
}
EDIT:
The current response I'm getting:
{
"status": "Failed",
"errors": [
{
"code": 401,
"message": "Authorization information is invalid."
}
],
"data": null
}
I just figured I missed out on the Signature (see below instruction) but wasn't sure how to render it and where it goes exactly in the request?
X-WallTech-Date
EEE, dd MMM yyyy HH:mm:ss zzz
Authorization
WallTech <Access Token>:<Base64 Encoded HMAC SHA-1 Hash>
Signature String
<HTTP Verb> + "\0x000A" + <X-WallTech-Date Header> + "\0x000A" + <Full URL>
.setRequestHeader "RequestName", "application/json"
be:.setRequestHeader "Content-Type", "application/json"
-- and if the request needs to be sent via HTTPS, not just HTTP --- and if Authorisation header you're sending is correct (server might be expecting the string after WallTech to be base64 encoded). I think /services/shipper/orders should go in the URL (as you've done) so that's the correct, but you should also check if the JSON you're sending in request's body is valid.X-WallTech-Date: Tue, 06 Jan 2018 21:20:27 GMT
body
is not shown being defined or created.