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

Upload a file and return json api #171

Closed
joanmarcfeina opened this issue Aug 30, 2017 · 3 comments
Closed

Upload a file and return json api #171

joanmarcfeina opened this issue Aug 30, 2017 · 3 comments

Comments

@joanmarcfeina
Copy link

Hello!

I have been working with Saule library for some months succesfully but now I need to upload a file for processing and then return some data.
At first I did an endpoint and from postman I upload the file and some additional data with Content-Type: multipart/form-data header. The request reaches the endpoint and after a couple of seconds I get the json response.

Now I need the same but I need the json response to follow the json standards with relationships, links and so on.
Here's the code I am using:
`

    [Route("booo/")]
    [ReturnsResource(typeof(BooResource))]
    [HttpPost]
    public async Task<IHttpActionResult> FooFunction()
    {
       ...
       return Content(status, FooResult);
    }`

The problem I am facing is that if I make a post request with Content-Type: multipart/form-data I get an "415 unsupported media type" but if I change the content-type to application/vnd.api+json I can't read the file.

What can I do?

Thank you!

@joukevandermaas
Copy link
Owner

This seems like a duplicate of #167. Can you try the latest pre-release and see if that resolves your problem?

@joanmarcfeina
Copy link
Author

I tried the #167 with the latest Nuget version and it didn't work. You mean try the #167 with the pre-release?

@joukevandermaas
Copy link
Owner

I mean version 1.7.0.444-beta on nuget. I think #167 was fixed in #168, in the sense that you can now add the JSON API formatter to the end of the collection, so the regular multipart/form-data one gets a chance to run first.

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