Reputation: 23
I am using rest API for my project. I am trying to update a single value in users but having a hard time achieving this.
I keep getting the following error:
error CS1503: Argument 1: cannot convert from 'string' to 'Proyecto26.RequestHelper'
Here is an image of how the data is stored in the firebase database:
This error occurs on the following line.
RestClient.Put($"{databaseURL}users/{userId}/{nodeUpdate}:{valueUpte}.json").Then(response =>
However, if I do the following the error does go away but the update does not go through. I believe I am missing something that will allow the update to go through.
RestClient.Put($"{databaseURL}users/{userId}/{nodeUpdate}:{valueUpte}.json","").Then(response =>
I have read the documentation and so I proceeded to do the following approach below. It does update the database under that particular user id however, it removes the rest of the nodes that I have for the user and creates default nodes after the update is made.
public static void UpdateUserInfo(string userId, string nodeUpdate, string valueUpte, UpdateUserInfoCallback callback)
{
Debug.Log("UpdateUserInfo Method");
RestClient.Put($"{databaseURL}users/{userId}.json", (nodeUpdate,valueUpte)).Then(response =>
{
callback();
Debug.Log("The user info was successfully updated in the database");
});
}
I have also tried doing the following approach but this does not update the data:
RestClient.Put($"{databaseURL}users/{userId}/{nodeUpdate}.json", (valueUpte)).Then(response =>
{
callback();
Debug.Log("The user info was successfully updated in the database");
});
**Update: Was able to resolve issue by using JSON.Net to update value's. **
Upvotes: 0
Views: 1818
Reputation: 600006
You might want to have another look at the documentation for the REST API of the Firebase Realtime Database. You'll need to pass the value that is to be written as JSON in the body of the request, and not in the URL as you are trying.
Upvotes: 1