Back

[SOLVED] client.addHeader() not working

  • 0
  • Flutter
hortigado
2 Aug, 2023, 04:30

Hi, I'm trying to put a cookie in the header of the flutter sdk client. According to the addHeader function, it should work but I get the error because the value "Cookie" is not placed in the header of the request

TL;DR
The user is having trouble with the `client.addHeader()` function in Flutter SDK. They initially tried replacing the header with a cookie jar but it didn't work as expected. They were suggested to clear the app data or try using `jsonEncode()`. It is mentioned that the issue is specific to the SDK and not the API rest. There is a discussion about using the fallback cookies header instead, but the user is unsure if the cookie is modifiable through this method. Ultimately, they decide to copy the teams function from the project for now and hope for future updates to address this feature.
hortigado
2 Aug, 2023, 04:31

I don't know if it doesn't work or the Cookie is not modifiable through this method

Drake
2 Aug, 2023, 04:46

I wonder if it's being overwritten by the cookie jar 🧐

hortigado
2 Aug, 2023, 04:49

I think it is the more safest, I will have to copy the teams function in my project for the moment I hope this feature will be added in the future

Drake
2 Aug, 2023, 04:53

You can try using the fallback cookies header instead: https://appwrite.io/docs/rest

Drake
2 Aug, 2023, 04:54

Hmm there are no examples of the value in the docs

hortigado
2 Aug, 2023, 05:47

Indeed, the safest thing is that the cookie is replaced by cookie jar

Drake
2 Aug, 2023, 06:10

Your fallback cookie probably isn't formatted right

hortigado
2 Aug, 2023, 17:52

on api rest working but with the sdk not

hortigado
2 Aug, 2023, 17:53
Drake
2 Aug, 2023, 17:58

toString() is rarely the right approach. Can you try jsonEncode()?

hortigado
2 Aug, 2023, 18:02

Not working

Drake
2 Aug, 2023, 18:19

this is in mobile, right?

hortigado
2 Aug, 2023, 18:19

Yes

Drake
2 Aug, 2023, 18:21

oh nvm...looks like if it's in the cookie jar, it won't look at the fallback cookies. can you try to clear your app data?

hortigado
2 Aug, 2023, 20:39

Correct, that was the problem. I already had a cookie jar saved and replaced the header. Now if I work with the "Cookie" parameter or with "X-Fallback-Cookies"

hortigado
2 Aug, 2023, 20:39

Thank you

hortigado
2 Aug, 2023, 20:50

[SOLVED] client.addHeader() not working

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