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

Content-Type header is case sensitive in parseItem middleware #368

Closed
aramkoukia opened this Issue Mar 7, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@aramkoukia

aramkoukia commented Mar 7, 2016

I'm trying out the Azure Mobile App API and getting an error on making Patch calls.

GET and POST and DELETE works fine.

Here is what my url looks like:

PATCH http://mymobileappapi.azurewebsites.net/tables/Skill/c89027fa-edce-4d36-b42a-ecb0920ebab6
body:

{
  "name": "Leadership SDFF"
}

I have these as headers too (as I said other http verbs work.)

ZUMO-API-VERSION 2.0.0
Content-Type Application/Json

And I get 500 error back with this in the body:

{
  "error": "An item to update was not provided"
}

The same id works when I do a GET using that id...

And when I make the same call using same body with PUT i get a 404 Not found without any content in the response body.

Any ideas?

@danderson00

This comment has been minimized.

Contributor

danderson00 commented Mar 7, 2016

It turns out our implementation requires the content-type header value to be lower case, i.e. application/json works, whereas Application/Json doesn't. I've updated this issue to be the placeholder for the fix. As a workaround in the meantime, make the value for the content-type header lower case.

https://github.com/Azure/azure-mobile-apps-node/blob/master/src/express/middleware/parseItem.js#L27 should use req.get instead of req.headers. Keep in mind that values can also include encoding, e.g. application/json; charset=utf-8

@danderson00 danderson00 changed the title from Azure Mobile App API Returns 500 on PATCH Http call to Content-Type header is case sensitive in parseItem middleware Mar 7, 2016

@aramkoukia

This comment has been minimized.

aramkoukia commented Mar 7, 2016

Yes, this fixes the issue, thanks for the quick turnaround.

@danderson00 danderson00 added this to the v2.0.2 milestone Mar 9, 2016

@danderson00

This comment has been minimized.

Contributor

danderson00 commented Mar 23, 2016

Resolved by 6cba43d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment