Summary
Getting a api.context.invalid_body_param.app_error on Post request to create user.
Steps to reproduce
Running my code with a random email and username
Ruby Version: 2.3.1
Mattermost Version: 5.7.0
API: V4
Expected behavior
Creation of a user.
I am trying to create a User via a ruby script in which username email and password are all generated. I am using HTTParty for the api requests and post JSON formated parameters. The variables all have the correct values for username an email attached to them.
creation_hash.each do |account_creator|
pass = generate_password(12)
creation = HTTParty.post(‘http://XXXXXX:8065/api/v4/users’,
headers: {
“Authorization”: “Bearer gcyyj4w1tfgq7yxkmtt4cmpg3y”,
“cache-control”: “no-cache”,
“Content-Type”: “application/json”
},
body: {
“email”: “#{account_creator[1].first}”,
“username”: “#{account_creator[0].first}”,
“password”: “#{pass}”
}
)
end
Observed behavior
Following Error Code:
{“id”:“api.context.invalid_body_param.app_error”,“message”:“Invalid or missing user in request body”,“detailed_error”:"",“request_id”:“ID”,“status_code”:400}
I am unsure maybe there is an error in my HTTParty post request but i am pretty sure i am sending valid JSON to the API.
Thanks in advance.