Get HTTP response using Token
Hi Guys,
I'm using the below code to get a JSON file using a Token, I can get json file with not problem from the the command prompt as below,
curl -X 'POST' \
'https://vibra-api-dev.azurewebsites.net/api/jobs' \
-H 'accept: */*' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOiIxNCIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL2VtYWlsYWRkcmVzcyI6ImFzYWJvNjQ3MzhAZ21haWwuY29tIiwiUGVybWlzc2lvbiI6WyJBY2NvdW50X01hbmFnZW1lbnQiLCJXb3JrUmVxdWVzdF9DcmVhdGUiLCJXb3JrUmVxdWVzdF9WaWV3TGlzdCIsIldvcmtSZXF1ZXN0X0FwcHJvdmUiLCJXb3JrUmVxdWVzdF9TY2hlZHVsZVdvcmtPcmRlckFjdGl2aXR5IiwiV29ya1JlcXVlc3RfQ2FuY2VsIl0sImV4cCI6MTY1MTY5Nzg1MSwiaXNzIjoiR2FsYXh5QXBpIiwiYXVkIjoiaHR0cHM6Ly92aWJyYS1hcGktZGV2LmF6dXJld2Vic2l0ZXMubmV0In0.O7WFmDZVWEUx26o3G8iZ-pULBoprZviq9yaCP0572Gk' \
-d ''
but my code in my class method is not working, what an I missing?
Set Httprequest.SSLConfiguration="RTLS"
Set Httprequest.Server="serverurl"
Set Httprequest.Https=1
Set Httprequest.Timeout=30
S Token="sometoken_value"
set Httprequest.ContentType="application/json"
Do Httprequest.SetHeader("Accept","
Do Httprequest.SetHeader("Authorization","Bearer "_Token)
set tSc = Httprequest.Post("/api/jobs")
//S Resp=Httprequest.HttpResponse.Data.ReadLine()
Set Resp=Httprequest.HttpResponse.Data.Read()
Quit Resp
thanks
It looks like in your curl you have the Accept header as */*, but in your HttpRequest object, you're setting it to "application/json". Does that make a difference?
Nope, changed it to */* and didn't make any diffrence.
in the Token there are "." & "_" special charachters not sure if that cause problem, I tried removed them but still no luck.
Set Httprequest.Server="vibra-api-dev.azurewebsites.net"
I have also never needed to use: Set Httprequest.SSLConfiguration="RTLS"