cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

consuming external API

davidcor
1-Newbie

consuming external API

I'm trying to use an external API that requires a curl request. Is this possible using the content loader functions?

6 REPLIES 6

Hi David,

I think the functions in 05.01.03.03 ContentLoaderFunctions, specifically GetText will be perfect for this (but also check the other functions there).
Available of course in the snippets :)

BR,
Vladimir



can you provide me with an example? I'm trying to use an API that requires the request

curl https://api.domain.com/v2/shipments \
-u {YOUR API KEY}:

I've used GetXML for other APIs but can't see how I would be able to consume this one.



I've tried this:
var url = https://api.domain.com/v2/shipments
var params = {

    url: url /* STRING /,<br>    username: apiKey / STRING */,
};
var result = Resources["ContentLoaderFunctions"].PostText(params);

but get "unauthorized 401" as a response.



paic
1-Newbie
(To:davidcor)

are you having trouble with the spaces and the slash? Did you try using things like %20 or escape characters?

Pai - I don't see what you mean.  there are no spaces in the url.  I opened a ticket with support and they said that the code below worked, but I still receive an unauthenticated error

result = Resources["ContentLoaderFunctions"].PostJSON({
url: "https://api.easypost.com/v2/shipments",
password: "",
username: "d7WlVQmMEFlzQ5a9GvbfXA",
timeout: 30
});



adam11
5-Regular Member
(To:davidcor)

David,

I assume you replaced the example API key I supplied as the value for username with the API key associated with your account?

Announcements


Top Tags