Calling SharePoint 2013 REST API with FBA Turned On -
i have following code works fine forms based authentication turned off, moment turn on stops working:
string baseurl = siteurl + "/_api/"; string uristring = "web/lists/getbytitle('" + listname + "')/fields/getbyinternalnameortitle('" + displayname + "')"; networkcredential cred = credentialcache.defaultnetworkcredentials; system.net.http.httpclient client = new system.net.http.httpclient(new httpclienthandler() { credentials = cred }); client.baseaddress = new uri(baseurl); client.defaultrequestheaders.add("accept", "application/json;odata=verbose"); servicepointmanager.servercertificatevalidationcallback = delegate(object s, x509certificate certificate, x509chain chain, sslpolicyerrors sslpolicyerrors) { return true; }; httpresponsemessage resp = client.getasync(uristring).result; string respstring = resp.content.readasstringasync().result;
the response follows:
{statuscode: 403, reasonphrase: 'forbidden', version: 1.1, content: system.net.http.streamcontent, headers: { transfer-encoding: chunked x-sharepointhealthscore: 0 x-forms_based_auth_required:...)
i have tried several things, including specifying farm account windows authentication credentials under on httpclient credentials object, have tried use authenticationheadervalue:
client.defaultrequestheaders.authorization = new authenticationheadervalue("basic", _formatbasicauth("domain", "username", "password"));
any highly appreciated.
for experiencing issue resolved going site permissions , setting anonymous access entire website.
Comments
Post a Comment