0

I am working on MS SharePoint 2013 integration and in my use case I want to work on JSON data only.
I am able to convert all the API XML responses like File, Folder, List, ListItem, etc into OData JSON using Node Module - datajs_vanilla, but I am not able to convert https://mysite/_api/$metadata into OData JSON. I am getting below error while executing datajs for $metadata endpoint:

error:{"message":"no handler for data"} 

Below is my code snippet:

OData.read({
        requestUri: 'https://example.com/_api/$metadata',
        headers: {
                    'Authorization': 'Bearer token_value',
                    'Accept':'application/xml;charset=utf-8' 
                 } 
        }, function (data, response) {
            console.log("Operation succeeded."+JSON.stringify(data));
    }, function (err) {
        console.log("Error occurred " + JSON.stringify(err));
});

I am missing something here to convert into JSON?
or
Could you please suggest me possible solution to convert edmx sharepoint $metadata XML response into OData JSON using node module?

Thanks.

1 Answer 1

1

See answer for similar question Get OData $metadata in JSON format .

Metadata document is not defined using OData atom/xml format that's why datajs vanilla is failing to parse it. Metadata format is CSDL format. Example of metadata doc - http://services.odata.org/V4/TripPinServiceRW/$metadata.

Usually metadata used for discovery and client generation since it has type info and all entity relations. Having service responses being serialized to json and service documentation in json should be sufficient for you to work with service.

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for the reply. Could you please suggest the best way to read the $metadata and would like to retrieve "Folder" object metadata in node js.
I think this thread should help you - stackoverflow.com/questions/5672151/…
File and folder api reference with corresponding Json representation can be found at msdn.microsoft.com/en-us/library/office/dn450841.aspx#bk_Folder
Forgot to mention that you don't need to do conversion , you have to specify in header that Api response need to be in Json headers: { "accept": "application/json; odata=verbose"
yes, i know this part. i wanted to convert object metadata like Files, Folder so that i could create entity of that. that why I was asking you how can I retrieve specific object metadata from it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.