Back

[CLOSED] updatePhone - NodeJS SDK - 400 response - Cloud Beta

  • 0
  • Users
  • Cloud
WasklyWabbit#1
28 Aug, 2023, 17:24

This is the call from my NodeJS server to the SDK;

TL;DR
The user was trying to update the phone number of an Anonymous account using the Appwrite NodeJS SDK. They received a 400 response error, but upon further investigation, it was found that the error was due to not setting a phone number rather than a problem with the SDK. The user was confused because the API server was reporting the parameters it received instead of returning the error from Appwrite. The user also mentioned some confusion between using the "users" API and the "account" API. In the end, it was determined that the user's scenario required using the "account" API because the user didn't have a password. The
WasklyWabbit#1
28 Aug, 2023, 17:26

When I make the same call from the appwrite Function (which uses an older SDK) there's no error

Drake
28 Aug, 2023, 17:28

This looks like account service/API rather than the user service/API 🧐

WasklyWabbit#1
28 Aug, 2023, 17:30

You're right, this is the one from node-appwrite.users

Drake
28 Aug, 2023, 17:30

Why are you using the account API?

WasklyWabbit#1
28 Aug, 2023, 17:31

The user doesnt have a password, in this scenario, so cannot use "users"

Drake
28 Aug, 2023, 17:31

I don't understand

WasklyWabbit#1
28 Aug, 2023, 17:32

oauth login - the user/session doesnt have a password, which is a required parameter for users.updatePhone

Drake
28 Aug, 2023, 17:33

So you want to use the users API, right?

WasklyWabbit#1
28 Aug, 2023, 17:34

ideally, but i cant

Drake
28 Aug, 2023, 17:34

I'm lost again...the users API doesn't require a password

WasklyWabbit#1
28 Aug, 2023, 17:36

Checked the docs - and it does for Client, but not for Server - i hadnt noticed that subtlety and though I had to use account

WasklyWabbit#1
28 Aug, 2023, 17:37

ignore that, I'm getting myself mixed up on the calls/ docs

Drake
28 Aug, 2023, 17:37

Account API is used when you have a JWT token and you want to make requests on behalf of the user.

That said, there is a bug with the update phone API for users created using oauth2.

Drake
28 Aug, 2023, 17:38

So this is your node server code that doesn't work? What exactly is appWrite and updatePhone?

WasklyWabbit#1
28 Aug, 2023, 17:38

appWrite is just an api wrapper

Drake
28 Aug, 2023, 17:40

And I assume that users is the Appwrite Users service? And if you click into the implementation details of that updatePhone()?

WasklyWabbit#1
28 Aug, 2023, 17:40

the server handles web page, wss, and API so common services are pulled out, that's all

WasklyWabbit#1
28 Aug, 2023, 17:40

Implementation....

Drake
28 Aug, 2023, 17:41

So it does look like it's number in the payload...but you said it was sending as phone?

Drake
28 Aug, 2023, 17:42

I assume the extra S in that function name was added right before you send this screenshot?

WasklyWabbit#1
28 Aug, 2023, 17:43

Ignore the extra "s" - i hit the keyboard

WasklyWabbit#1
29 Aug, 2023, 06:04

[CLOSED] updatePhone - NodeJS SDK - 400 response - Cloud Beta

Drake
29 Aug, 2023, 16:59

So what was the problem in your nodejs server code?

WasklyWabbit#1
30 Aug, 2023, 06:28

It seems you cannot update the phone number of an Anonymous account - error was you cannot update the phone number unless one has been set (which is a different issue, so closing this). The response error of number vs phone was my API server reporting the parameters it received, whereas it was supposed to be returning the error from appwrite

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more