Page 1 of 1

Server Code external API

Posted: Thu Jul 31, 2014 8:44 pm
by Beej

Hello,

Have a server code script that's working great, but when I try to use it to access a 3rd party API, I get a "502 Bad Gateway" error.

Not sure who's end the error is on.

Is what I'm attempting even possible? If so, what might be causing it?


Server Code external API

Posted: Thu Jul 31, 2014 10:39 pm
by Yurii Orishchuk

Bi Beej,

Please specify: do you can access your 3rd party api via other tools?(like postman https://chrome.google.com/webstore/de...)

In general it seems to be problem with your 3rd party api server.

Also see about 502 error here
http://www.checkupdown.com/status/E50...

Regards.


Server Code external API

Posted: Fri Aug 01, 2014 2:01 am
by Beej

It's likely an issue with the 3rd party library (Evernote SDK). It probably doesn't send the ajax request properly.

Speaking of which, I have another one right now. The only way it works in Postman is to send it in raw JSON format. Is there any way to get this to work in Server Code? Cannot get any version of "XHR.send" to work.


Server Code external API

Posted: Fri Aug 01, 2014 2:37 am
by Yurii Orishchuk

Hi Beej,

Please provide us settings for Postman, which is you use for correct response(use text and screen shots).

We will take a look and will try to provide a solution for you.

Regards.


Server Code external API

Posted: Fri Aug 01, 2014 5:50 am
by Beej

This is the only thing I've gotten to work so far (in Postman).

Image


Server Code external API

Posted: Fri Aug 01, 2014 6:17 am
by Beej

Actually, just got it to work by putting the JSON object in the body (thanks!):

prevar url = 'https://mydomain.auth0.com/oauth/token';
var postData = {
"parameters": {},
"headers": {
"Content-Type": "application/json"
},
"body": {
"client_id": "GU...Pa",
"client_secret": "Wr...JM",
"grant_type": "client_credentials"
}
};
XHRResponse = XHR.send('POST', url, postData);
/pre


Server Code external API

Posted: Fri Aug 01, 2014 1:49 pm
by Evgene Karachevtsev

Hello Beej,

Thank you for the update, glad it works!