Hey,
I'm trying to create an account with API.
What I have
return httpModule.request({ url: "https://url.com/index.php/rest/V1/customers", method: "POST", headers: { "Content-Type": "application/json" }, content: JSON.stringify({ customer: { email: user.email, firstname: user.firstname, lastname: user.lastname }, password: user.password }) }).then( response => { console.log(response.content.toJSON()); return "Register Success"; }, error => { console.log(error); return "Error"; } );
And always gives me
{ "message": "\"%fieldName\" is required. Enter and try again.", "parameters": { "fieldName": "customer" } }
What is wrong here? I've tried doing with string directly but always the same.
If I check the logs
Fatal Error: 'Allowed memory size of 2147483648 bytes exhausted (tried to allocate 266240 bytes)
I can't understand this.
Thanks in advance.
Best regards,
Rui Silva
Hello @rui_silva1
In the above screenshot you can see the header is of json format and the body is sending in stringy format, can you try to send data in JSON format, then it should work.
The format should be like below :
{ "customer" : { "lastname" : "Doe", "firstname" : "Jane", "email" : "doe@example.com" }, "password" : "Password1" }
Hope it helps !
Hey @gaurav_harsh1 ,
Thanks for your reply! If I use it that way it does not create the account, just returns with an empty response and gives an error in the app.
How can I debug this?
Thanks!
Best regards,
Rui Silva