I have a client that no longer wants to use sftp to transmit their data file to me. Instead they want me to pick it up via a web service.
Email from client:
Here is the postman collection and mocking service to start your development. The API has only one URI parameter {id} for which you need to pass UniqueIdentifier(will let you know exact value later).
attachments: ssrg-exp-api.postman_collection.json, IB006_Response.json
When going to the link supplied via a web browser ( {id} should be part of the link ), I see the results desired: ![](/sites/default/files/inline/images/webbrowser_results.png) But when I use my code from within Cache, I'm getting html code:
SRG>d GET^KCSAPI
Cache code:
K S $ZT="^%ET"
Can someone point me in the right direction and/or let me know where the error lies in my code. Why am I not able to pull the desired results? (as shown in the screen snippet).
</body>
</html>
s id="{id}"
set httprequest = ##class(%Net.HttpRequest).%New()
set httprequest.SSLConfiguration = "HTTPS"
set httprequest.Server = "www.anypoint.mulesoft.com"
set httprequest.Location = "/mocking/api/v1/links/03a74865-d7fb-4318-a310-7ad2b95361f6/v1/receivables/"_id
set httprequest.Https = 1
set httprequest.ContentType="json"
set sc=httprequest.SetHeader("Connection","close")
set status = httprequest.Get("/") ;returns html page
//s status = httprequest.Get("") ;returns msg: {"code":"INVALID_RESPONSE_ACCEPT_HEADER","message":"Error trying to find response for invalid media type"}
//set status = httprequest.Get("anypoint.mulesoft.com/mocking/api/v1/links/03a74865-d7fb-4318-a310-7ad2b95361f6/v1/receivables/9") ;commented out httprequest.Location - returns same html page
if status {
s response=httprequest.HttpResponse //IS JUST RETURNING PAGE
do response.Data.Rewind()
do {
write response.Data.Read()
} while 'response.Data.AtEnd
}
quit