1

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?

Thomas Deutsch
  • 2,344
  • 2
  • 27
  • 36
  • Hello. When I test you code I get No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. This is the same question I have posted here: http://stackoverflow.com/questions/26083657/accesing-sharepoint-online-from-various-clients – espenk Sep 30 '14 at 09:23

2 Answers2

1

_/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.

RainerAtSpirit
  • 3,723
  • 1
  • 17
  • 18
  • That's a good point. Although with breeze you can define the metadata on the client, and then use the new JsonResultsAdapter functionality to process the OData v3 json. Haven't tried it, but ... – Jay Traband Mar 16 '13 at 04:30
  • See Breeze 1.4.4, OData v3 support. – Jay Traband Oct 15 '13 at 21:00
0

As of Breeze 1.4.4, Breeze now supports OData v3.

Jay Traband
  • 17,053
  • 1
  • 23
  • 44
  • 1
    Good to know, but is that really an answer to the question *translate this jQuery-Ajax call into breeze.js* ... or push me in the right direction? ;-) – RainerAtSpirit Oct 15 '13 at 21:52