Question
· May 17, 2022

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 = ##class(%Net.HttpRequest).%New()
  Set Httprequest.SSLConfiguration="RTLS"                              
  Set Httprequest.Server="serverurl"                 
  Set Httprequest.Https=1
  Set Httprequest.Timeout=30
  Token="sometoken_value"
   set Httprequest.ContentType="application/json"
Do Httprequest.SetHeader("Accept"," application/json")
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

Product version: Ensemble 2014.1
Discussion (3)1
Log in or sign up to continue