Closed Cizzl closed 1 year ago
Thanks for the bug report! Out of curiosity, does doing the following work?
ModeledResponse<Product> response = await Client.From<Product>().Get();
Product model = response.Models.FirstOrDefault();
model.Note = "Test";
var result = await Client.From<Product>().Update(model);
Thank you, it worked
I am also getting the same error when trying to run the project, with my supabase instance values,
var option = new ClientOptions();
option.Headers.Add("apikey", "apikey");
var client = new Postgrest.Client("https://<instanceName>.supabase.co", option);
// Get all Users
var users = await client.Table<User>().Get();
I even tried making api call, and got the same response
Ah, if you're going to use just the plain postgrest-csharp client outside of supabase-csharp - you need to specify the REST endpoint see here for endpoints (the supabase-client handles all of these for you).
So you need the following:
var option = new ClientOptions();
option.Headers.Add("apikey", "apikey");
var client = new Postgrest.Client("https://<instanceName>.supabase.co/rest/v1", option);
// Get all Users
var users = await client.Table<User>().Get();
Hello, I was also get this error when I try and Update a row, but after doing what you suggested for Cizzl I get Status Code 200 OK, but nothing updates in Supabase
ModeledResponse<UserCategory> dbRows = await Authentication.Client.Postgrest
.Table<UserCategory>()
.Filter("id", Postgrest.Constants.Operator.Equals, model.Id.ToString())
.Get();
var dbRow = dbRows.Models.First();
dbRow.Name = model.Name;
dbRow.IntervalString = model.IntervalString;
dbRow.Sound = model.Sound;
var result = await Authentication.Client.From<UserCategory>().Update(dbRow);
@ConnorIllingworth can you show me what your model looks like?
Yes, heres my model
[Table("usercategories")]
public class UserCategory : BaseModel
{
[PrimaryKey("id")]
public Guid Id { get; set; }
[Column("userid")]
public Guid UserId { get; set; }
[Column("created_at")]
public DateTime CreatedAt { get; set; }
[Column("sound")]
public int Sound { get; set; }
[Column("name")]
public string Name { get; set; }
[Column("interval")]
public string IntervalString { get; set; }
}
Try setting the following and inserting again please!
[PrimaryKey("id", false)]
public Guid Id { get; set; }
Although, false
will be the default for most use cases… so maybe it’s time to just set that as such in the PrimaryKey
attribute.
Bug report
Describe the bug
I followed the instruction of the docs. When I try to use the Update method I get this error message:
I have no issue with inserting or selecting. Also turned of my policies to test it.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
Expected behavior
Value should have changed.
System information