PractiTest Discussion Forum

Using API from Excel VBA

Hi, can I get example code of using API from Excel VBA? I am trying with something similar as described here ms access - Equivalent cURL in VBA? - Stack Overflow but always get authentication error.
Thanks, Kuba

Try with content-type application/json, instead of what’s described there:
HTTPReq.setRequestHeader “Content-Type”, “application/json”
Also, pay attention that in their example, they provide the parameter as is, and PT expects to get the parameters (of PUT / POST commands), in a json format.

Let us know if it worked or if you need any further assistance.

Thank Yaniv. Probably I should be more precise :). I haven’t done simple copy-paste, I have modified code from Stack Overflow like this:
TargetURL = “” //of course I used my Project Id
Set HTTPReq = CreateObject(“WinHttp.WinHttpRequest.5.1”)
HTTPReq.Option(4) = 13056 ’
HTTPReq.Open “GET”, TargetURL, False
HTTPReq.SetCredentials <MY_EMAIL>, <MY_TOKEN>, 0
HTTPReq.setRequestHeader “Content-Type”, “application/json”
MsgBox (HTTPReq.responseText)

And this give me Authentication Error.