Hello/Hi/Greetings,
I'm having some trouble trying to POST to a Piwigo installation (I'm just trying to log in currently). I've tried a few different methods, from a Python library, to CURL in Bash, to a Chrome app called Postman. No matter what, I keep getting this response back:
{"stat":"fail","err":501,"message":"Missing \"method\" name"}
This is on my own installation as well as the example one (URL listed below). For instance when posting thusly:
POST http://piwigo.org/demo/ws.php?format=json
Headers:
Content-Type: application/json
Data:
{"username":"somerandomstring","password":"someotherrandomstring"}
I don't understand what I'm doing wrong. Especially because if I go here to test it works fine:
http://piwigo.org/demo/tools/ws.htm#top
(using pwg.session.login).
I'd like to point out that I'm no developer by a stretch, but I have written python scripts in the past that do interface with APIs, and I'm just stuck and frustrated. Not sure what I'm doing wrong. Any help appreciated!
You cannot post using json. You must post form url encoded; you can only specify the output format.
Offline
Thank you. I'm not extremely experienced in dealing with APIs and manually making http requests so some things that may be obvious to others are not yet obvious to me :)
Based on what you said I used this header instead:
content-type: application/x-www-form-urlencoded
But it still keeps failing with the same response as before. I only assume I am missing some simple thing with the way I am setting the header. Any idea what that is?
I just noticed that if I use a url such as:
http://piwigo.org/demo/ws.php?format=js … ndomstring
Then the server responds saying the method name is invalid. Maybe I'm getting closer. I tried:
http://piwigo.org/demo/ws.php?format=js … sion.login
But the server responded by saying:
405 This method requires HTTP POST
But I had POSTed. I'm confused. This method parameter wasn't brought up in Piwigo's API Explorer, but it seems it might be a key...
If the tools/ws.htm works fine, then it's a problem because you didn't POST.
Offline
I was posting, but I think I found the problem. The form data needed to include a 'username' and 'password' of course, but also a 'method' needed to be sent in the form as well. The method in this case was 'pwg.session.login'.
I have the same issue.
What is the solution?
Offline