HTTP 406 లోపం SharePoint REST ఎండ్ పాయింట్లు వ్యతిరేకంగా కోణీయ $ http.get ఉపయోగించి చేసినప్పుడు

అప్డేట్: Marc AD ndersson pointed out this great piece of info: http://blogs.office.com/2014/08/13/json-light-support-rest-sharepoint-api-released/. That explains a lot :).

That may be the worst title of a blog post ever! Anyhoo.

I typically do all of my prototyping against an O365 instance. I have my personal instance so that I don’t have to be worried about affecting anyone else. జనాంతికంగా - మేము మాస్తో మా ల్యాప్టాప్లు వర్చ్యువల్ మిషన్ల కలియదిరిగారు కాల్ చేసినప్పుడు గుర్తుంచుకోవాలి - SQL సర్వర్, IIS, vs Hyper-V నిర్ణయం. VMWare? Anyhoo ...

నేను చేసే ఈ వాతావరణంలో కోణీయ ఉపయోగించి ఒక అనువర్తనం అభివృద్ధి చేసింది, ఇతర విషయాలు, ఈ:

$http.get(serverUrl)
.success(ఫంక్షన్(డేటా, హోదా, headers, config) {

var getLinksResponse = డేటా;

getLinksResponse.value.forEach(ఫంక్షన్(ఫలితం) {

// and so on and so froth

This was working just fine in two different SharePoint online environments. అయితే, when my colleague ported it to a Cloudshare instance, he was getting an HTTP 406 తప్పు (which was the first time I ever got that one, so … yay, I guess). We did a bit of research and noticed that the “Accept” header was off. SharePoint online was perfectly happy with:

Accept: application/json

But the cloudshare instance (which is SP on prem, hosted in a virtual server) wanted the classic “odata=verbose” added in as well:

Accept: application/json;odata=verbose

To fix that, we added the header as such:

var config = {headers: {
‘Accept’: ‘application/json;odata=verbose’
}
};

$http.get(serverUrl,config)
.success(ఫంక్షన్(డేటా, హోదా, headers, config) {

var getLinksResponse = డేటా;

getLinksResponse.value.forEach(ఫంక్షన్(ఫలితం) {

// and so on and so froth

That got rid of the 406, but it also changed the format of the response. It was more … verbose. (haha!) More changes were required and here’s the final result:

var config = {headers: {
‘Accept’: ‘application/json;odata=verbose’
}
};

$http.get(serverUrl,config)
.success(ఫంక్షన్(డేటా, హోదా, headers, config) {

var getLinksResponse = డేటా;

getLinksResponse.d.results.ప్రతి(ఫంక్షన్(ఫలితం) {

// and so on and so froth

ఈ మాత్రమే ఒక మారింది 30 మాకు నిమిషానికి సమస్య, కాబట్టి మేము బయటకు lucked. ఆశాజనక ఎవరైనా ఈ ఉపయోగకరమైన తెలుసుకుంటాడు.

</చివర>

2 "న ఆలోచనలుHTTP 406 లోపం SharePoint REST ఎండ్ పాయింట్లు వ్యతిరేకంగా కోణీయ $ http.get ఉపయోగించి చేసినప్పుడు

  1. Marc D Anderson

    పాల్:

    నేను మీరు JSON వుండగా ఎంపికను పట్టుబడిన అనుకుంటున్నాను ఆఫీసు బ్లాగులు న ఈ పోస్ట్ లో వివరించారు:
    http://blogs.office.com/2014/08/13/json-light-support-rest-sharepoint-api-released/
    ఆ మార్పు నుండి, మీరు ఒక విలువను తెలుపుటకు లేకపోతే, minimalmetadata కి సిద్ధంగా. నేను ఇంకా సంస్థాపిస్తుంది ఈ ప్రాంగణంలో దానిని చేసింది భావించడం లేదు, అందువలన డిస్కనెక్ట్.

    M.

ఒక Reply వదిలి పాల్ గాల్విన్ ప్రత్యుత్తరం రద్దు

మీ ఇమెయిల్ చిరునామా ప్రచురితమైన కాదు. లు గుర్తించబడతాయి *