1

I am playing with Meteor, and I am trying to make an API call to my apispark account, having a look at the Meteor Documentation: http doc

1 - Meteor.http.get("http://www.google.com")); works fine, returns me the google page.

2 - Meteor.http.get("https://myApi.apispark.net:443/v1/campaigns"));

Exception while invoking method 'getApiCampains' Error: failed [401] {"code":403,"description":"The server understood the request, but is refusing to fulfill it","reasonPhrase":"Forbidden"}

Which seems fine as I didnt provide any auth params.

3 - Meteor.http.get("https://myApi.apispark.net:443/v1/campaigns", {auth : '123:456'});

Exception while invoking method 'getApiCampains' Error: failed [401] {"code":401,"description":"The request requires user authentication", "reasonPhrase":"Unauthorized"}

Where 123 is my username and 456 is my private key. So that is basically what is wrong for me, the two previous examples are here to show that my api calls are working in general, but not this one.

Can anyone see what I am doing wrong here? As I checked one billion time, my credentials are the same one as the one from my account on apispark.

As it is the first time I am playing with Meteor HTTP package and making an API call, I could have easily forgotten something there, maybe some options or something ?

Any help or tips would be really appreciated ! Thanks

mokk
  • 916
  • 17
  • 35

1 Answers1

2

Could you make a try with curl to be sure that your credentials are correct? Here is a sample:

curl -u 123:456 https://myApi.apispark.net:443/v1/campaigns

I just did a try and it works for me. Be sure to use the credentials defined at the level of the Web API within the endpoint section. They are specific for your Web API and different from the ones of your account.

This link from the documentation could help you: http://restlet.com/technical-resources/apispark/guide/create/test.

Hope it helps you, Thierry

Thierry Templier
  • 198,364
  • 44
  • 396
  • 360
  • Thanks for the answer, but I have the same message: `{"code":401,"description":"The request requires user authentication","reasonPhrase":"Unauthorized"}` – mokk Jun 05 '15 at 15:03
  • Which is really strange as I checked again my credentials on my account, which are the one I am using. So it looks like it is more an issue with apiSpark and the credentials they gave me, than my code, but thanks for the tip, at least I know what is wrong :) – mokk Jun 05 '15 at 15:04
  • I updated my answer. I did a try and it works for me... I guess that you use the credentials from your account and not the ones from the Web API (section endpoints in the Web API overview page). Feel free to tell me if it fixes your problem. – Thierry Templier Jun 05 '15 at 15:13
  • That was it !!! :) :) I don;t think I can thank you enough ! I think what also confused me is that my username is the same for my normal account or for this endpoint, but the password is different. Thanks again ! – mokk Jun 05 '15 at 15:22