Could anyone help me?
I have my app connected to a REST API, but I can't seem to figure out how to get one item. I try to do this using the refit library.
So far I've got:
[Get("/Database/{num}/Likes")] Task<int> GetLikes(int num);
Which is in an API.cs interface
And in my MainPage.xaml.cs, I've got:
var nsAPI = RestService.For<API>("[LINK TO MY API]"); currentLikes = await nsAPI.GetLikes(Convert.ToInt16(swipeCardView.Id));
When I run the app, I got the error "Specified cast is not valid."
Answers
This error will occur when using the wrong type object. Try to add a breakpoint to debug to get which line code caused the error.
Similar issue cases you could refer to:
https://stackoverflow.com/questions/28263029/specified-cast-is-not-valid-error-in-c-sharp
https://stackoverflow.com/questions/6051713/specified-cast-is-not-valid