Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
923 views
in Technique[技术] by (71.8m points)

javascript - from jQuery-ajax to breeze.js (SharePoint ODATA example)

I am starting to use breeze.js for my ODATA service.

I am using a SharePoint ODATA api and i have an example of how to use it with jQuery-Ajax. To make this work with breeze would be so f-ing awesome. Can anyone help me to translate this jQuery-Ajax call into breeze.js ? ... or push me in the right direction?

$.ajax({
  url: “../_api/SP.WebProxy.invoke”,
  type: “POST”,
  data: JSON.stringify({
    “requestInfo”: {
      “__metadata”: { 
        “type”: “SP.WebRequestInfo” },
        “Url”: “http://get_my_data_from_this_url”,
        “Method”: “GET”,
        “Headers”: {
          “results”: [{
            "__metadata": { "type": "SP.KeyValue" },
            "Key": "Accept",
            "Value": "application/json;odata=verbose",
            "ValueType": "Edm.String"
          }]
        }
     }
  }),
  headers: {
    “Accept”: “application/json;odata=verbose”,
    “Content-Type”: “application/json;odata=verbose”,
    “X-RequestDigest”: $(“#__REQUESTDIGEST”).val()
  },
  success: successHandler,
  error: errorHandler
});

Here you can see an ODATA call to the SharePoint WebProxy. A neat feature to handle your cross domain calls!

I think the question at this point is: can i construct the data object with breeze.js?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

_/api is an OData v3 endpoint. AFAIK neither Breeze nor JayData support that fully at the moment. To make things worse _api/$metadata is not implemented in the release version of SP2013. Without the metadata document there's no way to automatically create the required data model.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...