Reputation: 49
I'm trying to use postman to make a post request to reset the password, to the wordpress site. Here is what query is obtained as a result: https://example.com/wp-login.php?action=lostpassword&user_login=User123
And in the end I get the answer: ERROR: Enter a username or email address. How to make a request correctly and is it even possible?
Upvotes: 2
Views: 2192
Reputation: 533
I got it!
What OP did wrong was sending the user_login
value in Postman's Params
instead of form-data
or x-www-form-urlencoded
.
Here is the working Postman request
But that's not all.
I am using Flutter for developing my mobile app and http
package to send the request and the normal http.post()
won't work. It only works with MultipartRequest
for some reason.
Here is the full working request for Flutter's http package.
String url = "https://www.yourdomain.com/wp-login.php?action=lostpassword";
Map<String, String> headers = {
'Content-Type': 'multipart/form-data; charset=UTF-8',
'Accept': 'application/json',
};
Map<String, String> body = {
'user_login': userLogin
};
var request = http.MultipartRequest('POST', Uri.parse(url))
..fields.addAll(body)
..headers.addAll(headers);
var response = await request.send();
// forgot password link redirect on success
if ([
200,
302
].contains(response.statusCode)) {
return 'success';
} else {
print(response.statusCode);
throw Exception('Failed to send. Please try again later.');
}
Upvotes: 5