Hello,
if you look through the FAQs you’ll find:
When I call an API the server returns 401 Invalid HTTP method. What should I do?
As outlined in the documentation some APIs must be called using the POST HTTP method (e.g. the Register API) and other using the GET HTTP method (e.g. the Posts API list). More info here.
If you are sure you have used the correct HTTP method be sure to check the settings of your web server. In particular, some users have reported that nginx has different URL mapping rules than Apache (see above).
Yes, I saw that in the FAQ.
However, is there an example of the correct html page code to actually do the POST command specifically for this API to pull the device ID, etc.?
Everything you’ll need is in the documentation page, with detailed format for every API.
Take a look at Chapter 4.1 Register API, you’ll find URL structure, parameters, sample HTTP requests and responses.
Just tried doing this:
http://mysite.com/pnfw/register?prevToken=old_device_id&token=new_device_id&os=iOS
However still results in the same error.
{“error”:”401″,”reason”:”Unauthorized”,”detail”:”Invalid HTTP method”}
Please read carefully the documentation.
You MUST use a POST request, not a GET request.
Yes I know, but do not understand how to create a form that specifically grabs the correct information and submits it.
Is there an actual example of the html (and additional script or whatever) to actually capture the email, name, and then hidden fields for device ID and OS, and then submit that information?
You can use CURL to send POST commands. As an example:
$ curl http://mysitename.com/pnfw/register/ --data "os=Android&token=test"
Hope it helps.
OK, I got as far as getting a web form to actually register a device into the WordPress database.
However, the token value just pulls in as “device_id” and not the actual long crazy string needed to push to iOS.
We’re encountering the same issue — even tried sending the CURL command via SSH, with the correct URL and Oauth token. Here’s what we get back in the Debug tab of PNFW Settings:
/pnfw/register/ API Error (401) from IP address <#.#.#.#>: Unauthorized, Parameter oauth_consumer_key is missing.
Can you please reply to my support ticket?
Hello,
are you sending the oauth_consumer_key parameter as specified in the RFC 5849? Please note the OAuth parameters must be added as query string parameters and not included in the Authorization header. This is because there is no reliable cross-platform way to get the raw request headers in WordPress.
Yes we are. We’ve tried with and without quotes.
Hi,
I am getting an error {“error”:”401″,”reason”:”Unauthorized”,”detail”:”Invalid HTTP method”} on calling the API to register a new token.
I am passing the following Firebase instance id (as the value for token) and the os value as Android as specified in the documentation. Please confirm if it’s appropriate or if i have done something wrong.
Thanks in advance!