4

I'm working on a SharePoint 2013 on premises Hosted App. The app needs to get data from an external REST endpoint from a web service on another computer. I've managed to get in Javascript the SP.WebProxy.invoke working fine (code below); except it hits the 200 Kb limit sometimes depending on the length of the JSON data in the response. Is this is there an alternative way of doing this call in Javascript or perhaps Node.js? As I understand it with the SP.WebProxy approach there is no way of increasing the 200Kb limit of the returned buffer.

Some one recently mentioned using the Service Bus. The environment is installed on Windows Server 2012 and the Service bus is configured but I've no ides how to implement this in a SharePoint App can anyone point me to a resource to get going every search I try keeps bring back Azure Service bus not Window Service bus

    $.ajax({
        url: "../_api/SP.WebProxy.invoke",
        type: "POST",
        dataType: 'json',
        data: JSON.stringify(
            {
                "requestInfo": {
                    "__metadata": { "type": "SP.WebRequestInfo" },
                    "Url": webServiceUrl,
                    "Method": "POST",
                    "Headers": {
                        "results": [{
                            "__metadata": { "type": "SP.KeyValue" },
                            "Key": "Accept",
                            "Value": "application/json;odata=verbose",
                            "ValueType": "Edm.String"
                        },
                            {
                                "__metadata": { "type": "SP.KeyValue" },
                                "Key": "Content-Type",
                                "Value": "application/json;odata=verbose",
                                "ValueType": "Edm.String"
                            }]
                    },
                    "Body": jsonData
                }
            }),
        headers: {
            "Accept": "application/json;odata=verbose",
            "Content-Type": "application/json;odata=verbose",
            "X-RequestDigest": $("#__REQUESTDIGEST").val()
        },
        success: function (data)
        {
            var jsonData = JSON.parse(data.d.Invoke.Body);
            DisplayResults(jsonData);
        },
        error: function (jqXHR, textStatus, errorThrown)
        {
            alert("Failure " + errorThrown);
        }
    });
  • Can you drop odata=verbose from the external source? Using odata=nometadata or odata=minimalmetadata to reduce the payload ? – Anders Aune Jul 12 '16 at 7:19
  • Hi Anders, Thanks for the suggestion. I've tried your idea to reduce the pay load using odata=nometadata but it still having the same issue some times the data exceeds 200Kb. I think I need an alternative to using SP.WebProxy to do my call. I have tried all sorts of ajax calls but the code posted above was the only one that worked others either failed to contact the web service. – Ian Fleet Jul 12 '16 at 8:21
  • I tried CSOM/JSOM but that didn't pass the JSON data properly as debugging the web service the values came through as defaults rather than what was sent. But this also used SP.WebProxy and will suffer the same issue – Ian Fleet Jul 12 '16 at 8:26

Your Answer

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

Browse other questions tagged or ask your own question.