Select to view content in your preferred language

How to securely access all sub folder of parent folder using REST API

1389
5
01-15-2021 02:45 PM
anuragmittal
Occasional Contributor

Hi,

I want to access all properties of parent folder using Rest API. Its a secured and I am trying to access it though token but not getting any success.

I am following this: https://developers.arcgis.com/rest/enterprise-administration/server/folder.htm

 

 

Tags (2)
0 Kudos
5 Replies
DavidPike
MVP Frequent Contributor

More info on your API call and error messages would help.

0 Kudos
anuragmittal
Occasional Contributor

Hi David,

I am using PHP curl to access the API. Below is the code. I am getting accessed denied error. Before reaching out to client, I want to know if this is the right approach ?

				if ( !function_exists( "\curl_init" ) )
				{
					\load_curl();
				}
				$curl = curl_init();
				curl_setopt_array($curl, array(
					CURLOPT_URL => "https://xxxxx/arcgis/rest/services/OSvC/OSvC_LandUse_Areas/MapServer?f=json",
					CURLOPT_RETURNTRANSFER => true,
					CURLOPT_ENCODING => "",
					CURLOPT_MAXREDIRS => 10,
					CURLOPT_TIMEOUT => 0,
					CURLOPT_FOLLOWLOCATION => true,
					CURLOPT_SSL_VERIFYPEER => 1,
					CURLOPT_SSL_VERIFYHOST => 2,
					CURLOPT_CAINFO => '/cgi-bin/' . cfg_get((120)) . '.db/certs/ca.pem',  
					
					CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
					CURLOPT_CUSTOMREQUEST => "GET",
					CURLOPT_HTTPHEADER => array(
						"Authorization: Bearer ".$token,
						"Content-Type: application/json"
					)
				));	
				
				$response = curl_exec($curl);
				$error = curl_error( $curl );
				$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);			
				curl_close($curl);

 

0 Kudos
anuragmittal
Occasional Contributor

Hi David,

My ultimate goal is to get all features layer that are in one particular folder. Let me know if there any other way to doing this. 

0 Kudos
anuragmittal
Occasional Contributor

 Hi All,

I am able to access the secure folder through browser by manually entering the credentials. But when I try to access it through REST API, I get Invalid Token error.

I am doing the below steps

  1. Generating the token using https://xxxxx/arcgis/tokens/generateToken API
  2. Then calling https://xxxxx/arcgis/rest/services/OSvC/?f=json REST API by passing generated token to access subfolder. But I am getting 'Invalid Token'
0 Kudos
VictorTey
Esri Contributor

Hi,I am not sure how u are passing the token but you can try the following

 

https://xxxxx/arcgis/rest/services/OSvC/?f=json&token=fdnfdasfdsajffsdfa