1

I am not sure what I am missing. I am trying to make a call to get a token returned via API. I need this token to do further calls - like create users, etc. Anyway, if I a similar call using GET to find the status, it works. Also, if I use the same information in this code in FIDDLER, it works and returns a token. Here is the Code:

Set oWinHttp = CreateObject("WinHttp.WinHttpRequest.5.1")

msgbox("body build")
sReqBody = "<Token>" &_
    "<Password>password</Password>" &_
    "<SiteCode>ABC1</SiteCode>" &_
    "<Username>Username1</Username>" &_
    "<Token>" 

msgbox("Building the POST")

sWebServiceURL ="http://testapi.releasecandidate-community360.net/api/token" 'Web Service URL
sWebhost =  "testapi.community360.net" 

msgbox (sWebServiceURL)
msgbox (sWebHost)

'POST the URL
oWinHttp.open "POST", "http://testapi.releasecandidate-community360.net/api/token", False
msgbox ("Set header")
'Set Header
oWinHttp.setRequestHeader "Content-Type", "application/xml"
oWinHttp.setRequestHeader "Accept", "application/xml"
oWinHttp.setRequestHeader "Host", sWebHost
oWinHttp.setRequestHeader "Content-Length", ""

msgbox("sending")
oWinHttp.send sReqBody
msgbox(sReqBody)
oWinHttp.WaitForResponse(120)
sResponse = oWinHttp.ResponseText
wscript.echo sResponse

The error is 404 - File or directiry not found.

This makes no sense since I can find that directory and FIDDLER tool works fine. I am guessing I need to talk to my Dev guys about the error messages we are returning.

But, any ideas what I am doing wrong with this? Thanks.

James Craig
  • 473
  • 3
  • 9
  • 22
  • 1
    Are manual and scripted request identical when you inspect them with Fiddler? If they're identical they should yield the same result. Also, you shouldn't need `WaitForResponse`, since you made the request synchronous. – Ansgar Wiechers Sep 30 '14 at 22:17
  • After removing `/api/token` from `sWebServiceURL` I got the other error [405 = HTTP verb used to access this page is not allowed](http://stackoverflow.com/questions/9854602/asp-net-web-api-405-http-verb-used-to-access-this-page-is-not-allowed-how). HTH. Adjusted `sWebServiceURL = "http://testapi.releasecandidate-community360.net"` and then used as follows: `oWinHttp.open "POST", sWebServiceURL, False` – JosefZ Oct 02 '14 at 19:43

0 Answers0