I'm using Pentaho to make an HTTP Post request using their REST Client. I simply want to change the value of a library's field in Sharepoint. (More details here).

enter image description here

If I make this POST request through postman, it changes the field to "Does this work?". This is what I want.


BODY Payload:

{"__metadata":{"type":"SP.Data.Data_x0020_SourcesItem"},"Import_x0020_Status":"Does this work?"}

Pentaho's REST Client output is:

The property '__metadata' does not exist on type 'SP.Data.Data_x0020_SourcesItem'. Make sure to only use...

This is a SharePoint error but it's not happening when I request from postman, only in Pentaho's REST client. I get this may be a Pentaho issue, but am trying to better understand the Sharepoint error so I can fix Pentaho's payload.

It's getting 400s in the logging, which means the request was malformed. I checked the JSON payload and its valid JSON. Likewise, the body field is of type JSON.

enter image description here

enter image description here

  • open up "fiddler" and perform both operations and look at the payload
    – Mike
    Apr 3 '18 at 17:32
  • @Mike what "Fiddler"?
    – Growler
    Apr 3 '18 at 17:44
  • @Mike please see above update
    – Growler
    Apr 3 '18 at 18:40
  • It's quite hard to figure out what's wrong when there is no code -- they are 3rd party plugins/apps. We can't diagnose it line by line.
    – Mike
    Apr 9 '18 at 14:51

One case when this error often happens is when you set ContentType request header as "application/json" instead of "application/json;odata=verbose".

  • querk number #369 - brutal
    – wal
    Oct 8 at 3:27

What are you sending as the header? Here's an example usable with JavaScript:




{ "accept": "application/json;odata=verbose",
                   "content-type": "application/json;odata=verbose",
                   "X-HTTP-Method": "MERGE",
                   "If-Match": "*",
                   "X-RequestDigest": "__yourRequestDigest__"}

The Body:

{ "__metadata": { "type": "SP.ListItem" }, "Title": "New title" }

The "X-RequestDigest": "__yourRequestDigest__" is needed for SharePoint Online.

Try changing your type to: "type": "SP.ListItem"


Setting Rest Call methods work with data

The endpoints in the SharePoint REST service correspond to the types and members in the SharePoint client object models. By using HTTP requests, you can use these REST endpoints to perform typical CRUD operations against SharePoint entities, such as lists and sites.

SharePoint REST Call HTTP Methods to read Resources

Read more about Representational State Transfer (REST) service for SharePoint at: Get to know the SharePoint REST service

Your issue

Let me see if I can point you in the right direction as well as provide a snippet you may manipulate to get you toward solving this issue you are having.

I cannot comment as I do not have enough points (Yet). However, I do have a question to you. Are trying to PUT something on site or GET something from the site? Also what is the _spPageContextInfo request using relative Server URL versus Absolute URL does make a huge difference.

    I defined mine as _spPageContextInfo call 
    my thought is if you define the SharePoint Context info to get the URL using either Server or Site Relative URL versus Absolute URL

    var siteRelativeURL = _spPageContextInfo.webServerRelativeUrl; // Or ("siteServerRelativeUrl")
    // versus
    var siteAbsoluteURL = _spPageContextInfo.webAbsoluteUrl; // Or
    //combine and return for Ajax call
    var url = siteRelativeURL + callURL;

    console.log(url) // http://sp.com/my/site/collection/sub/site/

    //However, they will both return http://sp.com/my/site/collection/sub/site/

    //The server reads as listed above yet really they are returned as listed

    //Relative will return as   = /
    //Absolute will return as = http://sp

    //BTW Feel free to Use this. I do not mind sharing any questions email me at jonathan.r.adcox@gmail.com
    jQuery.support.cors = true;            
    var siteURL = _spPageContextInfo.webServerRelativeUrl; //changing to this can help
    var url = siteURL + "/_api/web/lists/GetByTitle('carousel')/Items?$select=ID,Title,Category,photoAuthor,writeUp,File/ServerRelativeUrl,FileRef/FileRef&$expand=File/ServerRelativeUrl";  // returning a filter query may help to extend the property       

        url: url,
        method: "GET",//We are getting data not updating posting or removing data
        contentType: "application/json; odata=verbose",
        headers: { "Accept": "application/json; odata=verbose" },
        success: function (data)
            for(var i = 0; i < data.d.results.length; i++) 
                var item = data.d.results[i]; //define the data results
                var ID = item.ID;
                var Title = item.Title;
                var Category = item.Category;
                var Author = item.photoAuthor;
                var Para = item.writeUp;
                var Picture = item.FileRef;// this one set me on a trail for 5 days
                var listURL = "../carousel/Forms";
                var DispForm = listURL + "/DispForm.aspx?ID=";
                var titleURL = "<a href='"+DispForm+ID+"' target='_blank'>"+Title+"</a>";
                var UpForm = listURL + "/Upload.aspx";

                if (Category == "Featured")
                    $( "#netcomSlider" ).append( "<li><a href='"+DispForm+ID+"' target='_blank'><div class='slide' style=\"background-image: url('" + Picture + "');\"></div></a>" + 
                    "<div class='slide-text'>" + 
                    "<p><span class='header-text'>" + titleURL + "</span><br />" + 
                    "<br />Photo by:&nbsp;" + Author + "<br />" + 
                    "<br />" + Para + "<br /><br /><span><a href='"+UpForm+"' target='_blank'> + New Article</a></span></p>" +
                    "</div></li>" );

                animation: 'fade',
                autoplay: true,
                arrows: false,
                speed: 1000,    //  The speed to animate each slide (in milliseconds)  [default: 750]
                delay: 6000     //  The delay between slide animations (in milliseconds)  [default: 3000]
        error: function(data)  

Hope this may help or at least help to reexamine your code for possible resolution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.