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

Update list item Rest API: fixed the content-type value #6661

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mahajangaurav
Copy link

The content-type for the Update list item REST API was incorrect in the documentation example here. This PR fixes the example

Category

  • Content fix

Related issues

What's in this Pull Request?

Updated the content-type header value in the example to the correct value: "application/json;odata=verbose", instead of: "application/json", which does not work.

… item - updated the doumentation with the correct value
@VesaJuvonen
Copy link
Contributor

Docs Build status updates of commit 5a5ed8b:

✅ Validation status: passed

File Status Preview URL Details
docs/sp-add-ins/working-with-lists-and-list-items-with-rest.md ✅Succeeded View

For more details, please refer to the build report.

Note: Broken links written as relative paths are included in the above build report. For broken links written as absolute paths or external URLs, see the broken link report.

For any questions, please:

@andrewconnell
Copy link
Collaborator

I'm not sure this fix is correct... can you confirm this with an example? The content-type header has nothing to do with the metadata returned in the ODATA spec... it only defines what data is being SENT to the service.

@andrewconnell andrewconnell added Needs: Author Feedback Awaiting response from the original poster of the issue. Marked as stale if no activity for 7 days. pr:do-not-merge Pull request not ready to be merged labels Feb 5, 2021
@mahajangaurav
Copy link
Author

mahajangaurav commented Feb 11, 2021

Hi @andrewconnell

I understand what you are saying about the content-type header but the API returns a 400 if odata=verbose is not sent as part of the header. The error message returned is '__metadata does not exist on type 'SP.Data.DataItem'

The rest API seems to be expecting that value in the header

Jerry has also provided an example here in the original issue: #6636 (comment)

Other similar API calls expect this value for the content-type header as well, such as Create List Item, Delete List Item and a few others.

This is just a guess but from what I am reading this could have been done to support the Verbose JSON format in the OData 3.0 spec. More about this here (you are likely already familiar but just in case):
Verbose JSON Format:
https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-odata/c91c88d1-b477-46ed-bfa1-210b22ecf9ca
https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-odata/d91277b3-30dc-4195-9848-20f2f95c9ecf

Odata 3.0 spec discussing the json verbose format: https://www.odata.org/documentation/odata-version-3-0/json-verbose-format/

Based on what I read, it may have been done to support sending the __metadata as part of the request? FWIW, I tried with odata=minimalmetadata and that resulted in the same error.

Thanks!

@ghost ghost removed the Needs: Author Feedback Awaiting response from the original poster of the issue. Marked as stale if no activity for 7 days. label Feb 11, 2021
@mahajangaurav
Copy link
Author

@andrewconnell - just making sure you were able to review my earlier response. Please let me know if I can further assist in any other way. Thank you!

@andrewconnell
Copy link
Collaborator

I haven't looked at it... I help with triaging the issues & managing PR's, but only the quick stuff. Things that need more research, I do that in my spare time and been swamped lately. Can't make a commitment when I'll get back to this thread, or when MSFT will pick it up.

@andrewconnell andrewconnell added the status:to-be-reviewed Issue needs to be reviewed by Microsoft for additional follow up / review. label Mar 16, 2021
@andrewconnell andrewconnell self-assigned this Jun 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:do-not-merge Pull request not ready to be merged status:to-be-reviewed Issue needs to be reviewed by Microsoft for additional follow up / review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect value for the content-type for Update list item
3 participants