<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic AddFeatures token authentication in ArcGIS REST APIs and Services Questions</title>
    <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/addfeatures-token-authentication/m-p/1141172#M4073</link>
    <description>&lt;P&gt;I have a .NET Windows Service which succesfully can make geometry queries to a REST API using token authentication.&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I try to add a feature to a ArcGIS BigData Store using the add features API (&lt;SPAN class=""&gt;https://&lt;A href="https://sapqpnb2754.eur.corp.vattenfall.com/server/sdk/rest/02ss/02ss00000071000000.htm" target="_blank" rel="02ss/02ss00000071000000.htm noopener"&gt;&amp;lt;featurelayer-url&amp;gt;&lt;/A&gt;/addFeatures&lt;SPAN class=""&gt;(POST only)&lt;/SPAN&gt;&lt;/SPAN&gt;) I get the error message.&lt;/P&gt;&lt;P&gt;{"error":{"code":500,"message":"User does not have the privilege to perform this operation.","details":[]}}&lt;/P&gt;&lt;P&gt;Do I need to add special privileges to the user or how can I get the addFeature call work?&lt;/P&gt;&lt;P&gt;(The call works in the ArcGIS Server Manager web-tool, so that shouldn't be the case though).&lt;/P&gt;&lt;P&gt;This is how I acquire the token:&lt;/P&gt;&lt;P&gt;private string GetToken()&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp;try&lt;BR /&gt;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var request = (HttpWebRequest)WebRequest.Create("&lt;A href="https://xyz.com/server/tokens/generateToken" target="_blank" rel="noopener"&gt;https://xyz.com/server/tokens/generateToken&lt;/A&gt;");&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;request.Proxy = WebRequest.DefaultWebProxy;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;request.Credentials = CredentialCache.DefaultCredentials;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;request.Proxy.Credentials = CredentialCache.DefaultNetworkCredentials;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NetworkCredential networkCredential = new NetworkCredential("proxyuser", "pwd");&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;request.Credentials = networkCredential;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var postData = "username=user";&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;postData += "&amp;amp;password=pwd";&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var data = Encoding.ASCII.GetBytes(postData);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;request.Method = "POST";&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;request.ContentType = "application/x-www-form-urlencoded";&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;request.ContentLength = data.Length;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;using (var stream = request.GetRequestStream())&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;stream.Write(data, 0, data.Length);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var response = (HttpWebResponse)request.GetResponse();&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;string responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return responseString;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp;catch (Exception ex)&lt;BR /&gt;&amp;nbsp; &amp;nbsp;{ }&lt;BR /&gt;&amp;nbsp; &amp;nbsp;return null;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// This is how I post the feature&lt;/P&gt;&lt;P&gt;using (System.Net.WebClient client = new System.Net.WebClient())&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp;client.Headers["Content-type"] = "application/x-www-form-urlencoded";&lt;BR /&gt;&amp;nbsp; &amp;nbsp;client.Encoding = System.Text.Encoding.UTF8;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;var collection = new System.Collections.Specialized.NameValueCollection();&lt;BR /&gt;&amp;nbsp; &amp;nbsp;collection.Add("f", "json");&lt;BR /&gt;&amp;nbsp; &amp;nbsp;collection.Add("features", json);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;var response = client.UploadValues(uri, "POST", collection);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;MemoryStream stream = new MemoryStream(response);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;StreamReader reader = new StreamReader(stream);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;string responseStr = reader.ReadToEnd();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 07 Feb 2022 14:09:00 GMT</pubDate>
    <dc:creator>CarlErix</dc:creator>
    <dc:date>2022-02-07T14:09:00Z</dc:date>
    <item>
      <title>AddFeatures token authentication</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/addfeatures-token-authentication/m-p/1141172#M4073</link>
      <description>&lt;P&gt;I have a .NET Windows Service which succesfully can make geometry queries to a REST API using token authentication.&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I try to add a feature to a ArcGIS BigData Store using the add features API (&lt;SPAN class=""&gt;https://&lt;A href="https://sapqpnb2754.eur.corp.vattenfall.com/server/sdk/rest/02ss/02ss00000071000000.htm" target="_blank" rel="02ss/02ss00000071000000.htm noopener"&gt;&amp;lt;featurelayer-url&amp;gt;&lt;/A&gt;/addFeatures&lt;SPAN class=""&gt;(POST only)&lt;/SPAN&gt;&lt;/SPAN&gt;) I get the error message.&lt;/P&gt;&lt;P&gt;{"error":{"code":500,"message":"User does not have the privilege to perform this operation.","details":[]}}&lt;/P&gt;&lt;P&gt;Do I need to add special privileges to the user or how can I get the addFeature call work?&lt;/P&gt;&lt;P&gt;(The call works in the ArcGIS Server Manager web-tool, so that shouldn't be the case though).&lt;/P&gt;&lt;P&gt;This is how I acquire the token:&lt;/P&gt;&lt;P&gt;private string GetToken()&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp;try&lt;BR /&gt;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var request = (HttpWebRequest)WebRequest.Create("&lt;A href="https://xyz.com/server/tokens/generateToken" target="_blank" rel="noopener"&gt;https://xyz.com/server/tokens/generateToken&lt;/A&gt;");&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;request.Proxy = WebRequest.DefaultWebProxy;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;request.Credentials = CredentialCache.DefaultCredentials;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;request.Proxy.Credentials = CredentialCache.DefaultNetworkCredentials;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NetworkCredential networkCredential = new NetworkCredential("proxyuser", "pwd");&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;request.Credentials = networkCredential;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var postData = "username=user";&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;postData += "&amp;amp;password=pwd";&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var data = Encoding.ASCII.GetBytes(postData);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;request.Method = "POST";&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;request.ContentType = "application/x-www-form-urlencoded";&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;request.ContentLength = data.Length;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;using (var stream = request.GetRequestStream())&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;stream.Write(data, 0, data.Length);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var response = (HttpWebResponse)request.GetResponse();&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;string responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return responseString;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp;catch (Exception ex)&lt;BR /&gt;&amp;nbsp; &amp;nbsp;{ }&lt;BR /&gt;&amp;nbsp; &amp;nbsp;return null;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// This is how I post the feature&lt;/P&gt;&lt;P&gt;using (System.Net.WebClient client = new System.Net.WebClient())&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp;client.Headers["Content-type"] = "application/x-www-form-urlencoded";&lt;BR /&gt;&amp;nbsp; &amp;nbsp;client.Encoding = System.Text.Encoding.UTF8;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;var collection = new System.Collections.Specialized.NameValueCollection();&lt;BR /&gt;&amp;nbsp; &amp;nbsp;collection.Add("f", "json");&lt;BR /&gt;&amp;nbsp; &amp;nbsp;collection.Add("features", json);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;var response = client.UploadValues(uri, "POST", collection);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;MemoryStream stream = new MemoryStream(response);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;StreamReader reader = new StreamReader(stream);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;string responseStr = reader.ReadToEnd();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Feb 2022 14:09:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/addfeatures-token-authentication/m-p/1141172#M4073</guid>
      <dc:creator>CarlErix</dc:creator>
      <dc:date>2022-02-07T14:09:00Z</dc:date>
    </item>
    <item>
      <title>Re: AddFeatures token authentication</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/addfeatures-token-authentication/m-p/1414515#M4734</link>
      <description>&lt;P&gt;I had this problem too. Turns out you need an OAuth token and not the token from generateToken. The code I used is here: &lt;A href="https://gist.github.com/YikChingTsui/ff6d7b6126db73a77e5845576250177d" target="_blank"&gt;https://gist.github.com/YikChingTsui/ff6d7b6126db73a77e5845576250177d&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 03:00:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/addfeatures-token-authentication/m-p/1414515#M4734</guid>
      <dc:creator>Yik-ChingTsui</dc:creator>
      <dc:date>2024-04-24T03:00:50Z</dc:date>
    </item>
  </channel>
</rss>

