I am trying to send an image (StreamImageSource) to my backend but I recieve this error:
A Newtonsoft.Json.JsonSerializationException was thrown.
Self referencing loop detected for property 'Member' with type 'System.Reflection.MonoMethod'. Path 'photoData.Stream.Method.ReturnParameter'.
Is this related to my backend or has the error something to do with the way I am trying to send it?
This is what I am attempting to send from my contentpage, "imgPicked" is an image that gives me the value "Xamarin.Forms.StreamImageSource" when I run it in the the log:
async void createImage (object s, EventArgs a)
{
System.Diagnostics.Debug.WriteLine (imgPicked.Source);
//imgPicked.Source is a StreamImageSource
var create = await phpApi.createPhotoTwo (imgPicked.Source);
}
How I try to send it in:
static public async Task <bool> createPhotoTwo (ImageSource imgData)
{
var httpClientRequest = new HttpClient ();
var postData = new Dictionary <string, object> ();
postData.Add ("photoData", imgData);
var jsonRequest = JsonConvert.SerializeObject(postData);
HttpContent content = new StringContent(jsonRequest, System.Text.Encoding.UTF8, "application/json");
var result = await httpClientRequest.PostAsync("http://www.myadress.com/put.php", content);
var resultString = await result.Content.ReadAsStringAsync ();
return true;
}