Mattermost, Inc.

[Solved] Web Service doesn't work with Postman

Hi

I am trying to use the web service. When I use the cURL statement, it works. But I use Postman, it doesnt work.

this works:
curl -i -d '{"name":"test2","email":"test@test.com","password":"test"}' http://URL/api/v1/users/login

But the same thing on Postman gives me this error:
{ "id": "api.user.login.blank_pwd.app_error", "message": "Password field must not be blank", "detailed_error": "", "request_id": "6bspxjiejbdsuck7t1s5sfz65y", "status_code": 403, "is_oauth": false }

Any clue? Thanks so much.

Request sent from Postman was:

POST /api/v1/users/login HTTP/1.1 Host: URL Cache-Control: no-cache Postman-Token: aa8a7619-1ee7-059f-5c26-4982a8c7f6d7 Content-Type: application/x-www-form-urlencoded

name=test2&email=test%40test.com&password=test

This request did not work.

Hi @mittalvishesh,

It looks like your Postman request is url encoded and has a Content-Type of application/x-www-form-urlencoded. Our API requires a Content-Type of application/json and all POST bodies must be JSON formatted (which is what your curl is). You would need to tell Postman to change the Content-Type and possibly format the data yourself into JSON rather than using Postman’s auto key value formatter.

Hi @jwilander , Thank you. It worked!

1 Like