2

I'm currently trying to get a list of skills from the Alexa Skill Management API using PHP. My access token currently works to get user profile info and I'm 99% sure I gave the correct scope for permission to my Skill Development Account.

// exchange the access token for list of skills
$c = curl_init('https://api.amazonalexa.com/v0/skills/');
curl_setopt($c, CURLOPT_HTTPHEADER, array('Authorization: ' . $access_token));
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_VERBOSE, 1);

$r = curl_exec($c);
curl_close($c);
var_dump($r);

The above code returns the error: The requested method GET is not allowed for the URL /v0/skills/.

I'm sure I'm just making some silly mistake. Any help would be appreciated.

Optimus
  • 1,354
  • 1
  • 21
  • 40

1 Answers1

2

I have tried the same in POSTMAN but with POST instead of GET and looks fine (I got an Unauthorized error, which just because of token missing). It means the API you are trying to connect is not a GET method but post. So please try the request type as POST. Please see below the same API I have tried with POSTMAN

enter image description here

To make sure it is because of the problem with HTTP verb GET, I have reproduced the same error with GET. Please see below screenshot,

enter image description here

Please try add one line like below to make your request a POST,

curl_setopt($c, CURLOPT_POST, 1);
Vijayanath Viswanathan
  • 8,027
  • 3
  • 25
  • 43
  • I haven't had a chance to try this, but the documentation seems to contradict this: https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/skill-operations#list-skills – Optimus Sep 23 '17 at 18:41
  • 1
    I should trust official documentation. At the same time based on my investigation, I strongly believe it would be a POST. I don't have an access token to try it out. Please let me know after you try it out. I am really curious to know :) – Vijayanath Viswanathan Sep 23 '17 at 21:08
  • The response I'm getting now is that the token is invalid / expired, although it's the token I'm using to get the user profile information, so expired seems unlikely. – Optimus Sep 24 '17 at 13:34
  • I think I may need to refactor what I'm doing since I didn't get the access token from an authorization code response type. I'll report back after I do that. – Optimus Sep 24 '17 at 13:54
  • 1
    Cool. Still I stongly believe POST should work if sort out token issue. Because with the error message we were getting with GET has nothing to do with token or authorization. – Vijayanath Viswanathan Sep 24 '17 at 13:59
  • Ok the above 'works' now with 'User has not consented to this operation.' Although I'm perplexed at this new development I believe this is an acceptable answer. – Optimus Sep 24 '17 at 15:02
  • 1
    Excellent. Glad to know it is working now. Also a bit surprised on the confusion they made in the official documentation :) – Vijayanath Viswanathan Sep 24 '17 at 15:04
  • Well, it's not really working yet. Just a new error: https://stackoverflow.com/questions/46391553/user-has-not-consented-to-this-operation-alexa-skill-management-api – Optimus Sep 24 '17 at 15:13
  • 1
    Ohh ok. Let me check how we can sort out that. – Vijayanath Viswanathan Sep 24 '17 at 15:15