I am trying to interact with an API called ItemMaster (https://api.itemmaster.com/v2/api). I have read a number of posts, but am obviously missing some key points of how to do this.
Here is code, modeled after this post by Steve Wood( http://www.alphasoftware.com/alphafo...t=encoding+url), that I have tried both on an A5W page and in a UX component on a button using an Ajax callback:
I get this error, or a similar one: "Error:Could not connect to server: WSAHOST_NOT_FOUND - Host not found while getting host name.. Detailed Description: No such host is known. The name is not an official host name or alias, or it cannot be found in the database(s) being queried. This error may also be returned for protocol and service queries, and means that the specified name could not be found in the relevant database.
Error Number:16052.000000"
I am also confused by where to put the user name and password. The API documentation says to set both the username and password as separate http header parameters. Is this done in the request body, or using the pm.header parameter? If the latter, what is the correct way to specify multiple header parameters?
Here is code, modeled after this post by Steve Wood( http://www.alphasoftware.com/alphafo...t=encoding+url), that I have tried both on an A5W page and in a UX component on a button using an Ajax callback:
Code:
<%a5 debug(1) dim t_gatewayurl as c = "https://api.itemmaster.com/v2/brand" req = "<?xml version='1.0' encoding='utf-8' ?>" + crlf() + \ "<requests xmlns='http://www.w3.org/2001/XMLSchema'>" + crlf() + \ "<username:xxxxx>" + crlf() + \ "<password:xxxxxx>" + crlf() + \ "</requests>" dim url as c dim body as c url = t_gatewayurl dim pm as p dim pm.host as c = a5_split_url(url).protocol + "//" + a5_split_url(url).server dim pm.page as c = a5_split_url(url).page dim pm.port as n = 443 dim pm.method as c = "post" dim pm.header as c ="username:xxxxx""password:xxxxxxxx" dim pm.header as c = dim pm.ssl_on as l = .t. dim pm.body as c = req resp = http_fetch(pm) %>
Error Number:16052.000000"
I am also confused by where to put the user name and password. The API documentation says to set both the username and password as separate http header parameters. Is this done in the request body, or using the pm.header parameter? If the latter, what is the correct way to specify multiple header parameters?
Comment