Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example for PostAsync #11

Closed
Afshin1980 opened this issue Jul 25, 2017 · 4 comments
Closed

Example for PostAsync #11

Afshin1980 opened this issue Jul 25, 2017 · 4 comments

Comments

@Afshin1980
Copy link

Hello
i use hypermedia in Xamarin form and i am looking for a sample for using PostAsync method but i couldn't find it in your sample project .is it possible to give me an example for using PostAsync method for sending data to server.

@cosullivan
Copy link
Owner

Hi,

I just added this to the samples, have a look at this commit;
90fc4e5

Thanks,
Cain.

@Afshin1980
Copy link
Author

Thank you for your response
i use your sample for PostAsync and i get "415 unsupported media type" error but when i use GetAsync i can get the data from server

@cosullivan
Copy link
Owner

Hi,

Are you connecting to a Web API server, or some other server? If you are using Web API, can you make sure you have the JsonApi formatter configured?

https://github.com/cosullivan/Hypermedia/blob/master/Src/Hypermedia.Sample.WebApi/App_Start/WebApiConfig.cs#L46

Thanks,
Cain.

@Afshin1980
Copy link
Author

Afshin1980 commented Aug 21, 2017

thank you
i fixed the problem with adding following code to request header
      HttpContent Body = new JsonApiContent(comment, _contractResolver);
      Body.Headers.ContentType = new MediaTypeHeaderValue(MediaTypeName);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants