Accessing http URL from the application

610
16
02-21-2018 10:31 AM
VenkataSrikanth_Dasari
Occasional Contributor

Hi

I am accessing the REST service using esriRequest which is http URL from the portal linked web application.

however the application is accessing using https and response giving unable to load the url status 0.

Please give me solution for this.

Cheers,

Srikanth Dasari

0 Kudos
16 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Dasari,

   Portal urls are always https so your app that access the portal url should use https.

0 Kudos
VenkataSrikanth_Dasari
Occasional Contributor

I am accessing SharePoint REST Service URL (http) from the application https. Do I need to make SharePoint as a secured one??

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

mixed content is always a bad practice so yes.

VenkataSrikanth_Dasari
Occasional Contributor

Thank you 

0 Kudos
VenkataSrikanth_Dasari
Occasional Contributor

Even if its a bad practise, Could you please provide the solution??

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

You would have to share your code for that.

0 Kudos
VenkataSrikanth_Dasari
Occasional Contributor

var requestJson = {
method: "POST",
body: { '__metadata': { 'type': 'SP.Data.Data RequestListItem' }, 'Requestor': 'Test' }
//facilities: webMercatorUtils.webMercatorToGeographic(this.geom).x + "," + webMercatorUtils.webMercatorToGeographic(this.geom).y + ";",
////outSR: this.geom.spatialReference.wkid,
//token: this.token.token,
//defaultBreaks: [this.selectBufferUnits.value],
//f: "json"
};

esriRequest({
url: "http://sp/ops/Portal/_api/Lists/GetByTitle('ListItem')/items",
content: requestJson,
handleAs: "json",
withCredentials:true
}).then(lang.hitch(this, function (response) {
this._showError(response);
}), function (err) {
new Message({ titleLabel: "Warning", message: err.message });
});

Here is the code and getting the error in the console is below.

init.js:141 GET https://sp/ops/Portal/_api/Lists/GetByTitle('ListItem')/items?method=POST&body=%5Bobject%20Object%5D net::ERR_CONNECTION_TIMED_OUT
l @ init.js:141
b.xhr @ init.js:92
b.xhrGet @ init.js:92
w @ init.js:1010
g @ init.js:1013
A @ init.js:1019
(anonymous) @ init.js:1019
c @ init.js:103
C.then.then @ init.js:105
always @ init.js:112
C @ init.js:1019
_onBtnSubmitClicked @ Widget.js?wab_dv=2.6:102
(anonymous) @ init.js:63
init.js:89 f {message: "Unable to load //sp/ops/Portal/_api/Lists/GetByT…?method=POST&body=%5Bobject%20Object%5D status: 0", response: {…}, status: 0, responseText: "", xhr: XMLHttpRequest, …}

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Is the GetByTitle portion of your url a function that you are trying to call?

0 Kudos
VenkataSrikanth_Dasari
Occasional Contributor

There is a hierarchy in SharePoint..

Website --> List Items (Forms) --> items (Records)

In order to create a new record in one of the Form -->

https://sp/ops/Portal/_api/Lists/GetByTitle('FormName') --> Will give access to the form-->

https://sp/ops/Portal/_api/Lists/GetByTitle("FormName")/items --> Will give access to the records either to create or query

Cheers,

Srikanth Dasari  

0 Kudos