Hi, I have a curl that I want to send to API. (ACT! CRM).
The GET request work's with the code below:
Here the curl:
curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer xxxxxxxxxxxx' '
http://pc-gontran/Act.Web.API/api/Contacts'
Here the code:
'*************************
**********
**********
**********
**********
**********
******
oXMLHTTP.Open "GET", "
http://pc-gontran/Act.Web.API/api/Contacts", False
oXMLHTTP.setRequestHeader "Content-Type: ", "application/json" ''Content-Type: application/json'
oXMLHTTP.setRequestHeader "Accept: ", "application/json"
oXMLHTTP.setRequestHeader "Authorization: ", "Bearer " & strBearer
oXMLHTTP.Send
Do Until oXMLHTTP.ReadyState = 4
DoEvents
Loop
Me.txt_Status = oXMLHTTP.Status
If oXMLHTTP.Status = 200 Then
strHTML = oXMLHTTP.ResponseText
Me.txt_Response = strHTML
End If
'*************************
**********
**********
**********
**********
**********
******
Now when I try the same whit this curl:
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Bearer xxxxxxxxxxxxxxx' -d '{}' '
http://pc-gontran/Act.Web.API/api/Contacts'
Whit this code:
'*************************
**********
**********
**********
**********
**********
******
oXMLHTTP.Open "POST", "
http://pc-gontran/Act.Web.API/api/Contacts", False
oXMLHTTP.setRequestHeader "Content-Type: ", "application/json" ''Content-Type: application/json'
oXMLHTTP.setRequestHeader "Accept: ", "application/json"
oXMLHTTP.setRequestHeader "Authorization: ", "Bearer " & strBearer
oXMLHTTP.Send ("'{}'")
Do Until oXMLHTTP.ReadyState = 4
DoEvents
Loop
Me.txt_Status = oXMLHTTP.Status
If oXMLHTTP.Status = 200 Then
strHTML = oXMLHTTP.ResponseText
Me.txt_Response = strHTML
End If
'*************************
**********
**********
**********
**********
**********
******
When I try the curl in the API UI, it's working, but not in VBA (i'm in Access buy the way), I received a 400 error (bad server request).
Do you know what i,m doing wong?