• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Excel VBA - CURL - PUT - JSON - WinHttpRequest

I am trying to perform actions on a tool that supports API. I am using Excel VBA ("WinHttp.WinHttpRequest.5.1").

Code:
https://{domain}.zendesk.com/api/v2/suspended_tickets/1234567890/recover.json
   
domain - is the domain name of our company
1234567890 - dummy suspended ticket number

In the help pages of Zendesk, I found the following information.

Note: During recovery, the API sets the requester to the authenticated agent who called the API, not the original requester. This prevents the ticket from being re-suspended after recovery. To preserve the original requester, GET the suspended ticket before recovery and grab the author value.

This clearly says that the author would change and I will have to use the GET method to grab the author value. I have successfully grabed the author value from the ticket information (json file). However, I am not aware, how to send PUT request using the following cURL:

Code:
curl https://{domain}.zendesk.com/api/v2/suspended_tickets/1234567890/recover.json -X PUT -v -u {email@subdomain.com/token}:{token} -d '{"author": {"id": null, "name": "A customer", "email": "acustomer@example.com"}}' -H "Content-Type: application/json"
   
    domain - is the domain name of our company
    1234567890 - dummy suspended ticket number

I have used the following code to fetch (GET) information from the json file:

Code:
    TargetURL = "https://www.mysite.co.uk/app/api/v1/test"
    Set HTTPReq = CreateObject("WinHttp.WinHttpRequest.5.1")
    HTTPReq.Option(4) = 13056
    HTTPReq.Open "PUT", TargetURL, False
    HTTPReq.SetCredentials "user", "password", 0
    HTTPReq.setRequestHeader "Content-Type", "application/json"
    HTTPReq.send ({"author": {"id":null,"name":"FIRSTNAME LASTNAME","email":"name@emailaddress.com"}}) 
    MsgBox (HTTPReq.responseText)

Seeking insightful help from professionals and experts.

Regards....
 

alerte2.gif
double cross-posting with excelforum.com & ozgrid.com ‼
 
Back
Top