2

Attempting to pass some parameters to my custom API running on azure mobile service, using a List reference and Object to sent as parameters.Then I'm facing this Error.

Could not determine JSON object type for type App7.DataModels.FriendCircle.

FriendCircle friendcircle = new FriendCircle();
List<Invitee> inviteelist;
try
{

    Object[] ob = new Object[2] { friendcircle, inviteelist };
    await App.azure_rendezvous_mobile_service_3Client.InvokeApiAsync("saveinvite", new JObject(new JProperty("params", ob)));

} 
catch (MobileServiceInvalidOperationException ex) 
{
    System.Diagnostics.Debug.WriteLine("Exception is :" + ex.Message);

}
ivan_pozdeev
  • 33,874
  • 19
  • 107
  • 152
TheLoneWolf91193
  • 415
  • 7
  • 19
  • Can you attach the JSON string that is being generated from that and the data structure that is expected from your cloud service – Aydin Feb 01 '16 at 06:03
  • @AydinAdn did not understand what you said – TheLoneWolf91193 Feb 01 '16 at 06:17
  • When you are invoking the API, behind the scenes you are sending a JSON representation of your class to the API, The API is telling you the JSON object doesn't resemble anything it can determine – Aydin Feb 01 '16 at 06:20
  • @AydinAdn No, it does not happen as such ,all I want is to send a List type reference and an object to the Custom api, Any idea how this could be done? – TheLoneWolf91193 Feb 01 '16 at 06:23
  • Mate I can't help you if you ignore what I'm telling you, I can clearly see in your code you converting the object into a JSON object, and you've clearly posted the error that is complaining about a JSON object type. – Aydin Feb 01 '16 at 06:26
  • @AydinAdn how do I convert my object FriendCircle and List type reference to a JSON? – TheLoneWolf91193 Feb 01 '16 at 06:37

1 Answers1

1

I tried and was able to send a request to azure custom api.!! Serialized my List reference and Object friend circle to Json and hooked it up as Json Properties.

var jsoninviteelist= JsonConvert.SerializeObject(inviteelist);
var jsonfriendcircle = JsonConvert.SerializeObject(friendcircle);
await App.azure_rendezvous_mobile_service_3Client.InvokeApiAsync("saveinvite",new JObject(new JProperty("jsoninviteelist",jsoninviteelist),new JProperty("jsonfriendcircle", jsonfriendcircle)));

P.S Install Package>> Newtonsoft.Json from NuGet manager and use it as reference.

TheLoneWolf91193
  • 415
  • 7
  • 19