Hi;
I created the attached codeunit to communicate with External API via Rest method. How ever I'm getting an error upon run saying "The Remote Server returned an error: (504) Gateway timeout". I'm guessing it is because of the Authentication (combination of Authorization and Key). Here are the Requirements and what I did: (Please note that key I'm providing below is just a sample and not the actual (For security) )
xa3js8hmu3.execute-api.us-east-1.amazonaws.com/.../parts
HEADERS
Content-Type: application/json
x-api-key: LViHg8iYYa6VPZqhyemO92swvuo8RiZbage4Y4en
Authorization:
Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IlJqaEZNalpDTkRkRk1UY3dRamMwTURBeE5EZ3pOelkxT0RjMU5ERk
PROCEDURE UploadJson@1000000012(WebServiceURL@1000000000 : Text;String@1000000001 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.String");
VAR
HttpWebRequest@1000000002 : DotNet "'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.HttpWebRequest";
HttpWebResponse@1000000003 : DotNet "'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.HttpWebResponse";
BEGIN
CreateWebRequest(HttpWebRequest,WebServiceURL,'POST');
SetRequestStream(HttpWebRequest,String);
DoWebRequest(HttpWebRequest,HttpWebResponse,'');
GetResponseStream(HttpWebResponse,String);
END;
PROCEDURE CreateWebRequest@1000000015(VAR HttpWebRequest@1000000002 : DotNet "'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.HttpWebRequest";WebServiceURL@1000000001 : Text;Method@1000000000 : Text);
BEGIN
HttpWebRequest := HttpWebRequest.Create(WebServiceURL);
HttpWebRequest.Timeout := 300000;
HttpWebRequest.Method := Method;
HttpWebRequest.Accept := 'application/json';
HttpWebRequest.ContentType := 'application/json';
HttpWebRequest.Headers.Add('Authorization', dhbAuthText[1]+dhbAuthText[2]+dhbAuthText[3]+dhbAuthText[4]+dhbAuthText[5]+dhbAuthText[6]);
HttpWebRequest.Headers.Add('x-api-key','LViHg8iYYa6VPZqhyemO92swvuo8RiZbage4Y4en');
END;