0

I am trying to update a single attribute of a Firebase document. I am using Refit (c#, wpf)

        [Patch("/projects/super-project-name/databases/(default)/documents/users/{userId}?updateMask.fieldPaths=licence")]
        public Task UpdateUserLicence3(string userId, [Body] Fields licence);

I have a 400 bad request and I wonder if the Refit Query doesn't contain a mistake somewhere.

What I know :

  • Publishing the same request without the [Body] Fields licence=> remove my "licence" field" from my document and doesn't crash.

  • GET methods on single user works too.

Thanks by advance :)

Nearon
  • 71
  • 5

1 Answers1

3

Ok, I found out what was going wrong :

The actual 'licence' attribute wasn't correct (the body).

To fix it:

  1. I switch the 'type' from "Fields" to a string
  2. I put into my string, my following body :
{
  "fields": {
    "Licence": {
      "stringValue": "hello world!"
    }
  }
}

using a website link this : https://jsontostring.com/

Nearon
  • 71
  • 5