string replicaParams = GenerateRepliaceRequestJSON();
//string replicaParams = GenerateReplicaRequestForm();
string url = string.Format(@"{0}/{1}?token={2}", _currService, "createReplica", _tokenValue);
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Method = "POST";
webRequest.ContentLength = 0;
webRequest.ContentType = "application/json; charset=utf-8";
//webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.Accept = "application/json";
webRequest.Referer = txtBaseURL.Text;
byte[] postBytes = Encoding.UTF8.GetBytes(replicaParams);
webRequest.ContentLength = postBytes.Length;
using (Stream stream = webRequest.GetRequestStream())
{
stream.Write(postBytes, 0, postBytes.Length);
stream.Flush();
stream.Close();
}
using (HttpWebResponse response = webRequest.GetResponse() as HttpWebResponse)
{
using (StreamReader sreader = new StreamReader(response.GetResponseStream()))
{
string responseString = sreader.ReadToEnd(); // response here is html that says "Token required"I have the same question. I am using ArcRest to create replica in a .NET application. I know I need to pass in a username and password because the feature service is not public. I get the same error message you get because its looking for a token.
Just looking for an example on how this would be completed. If anyone has a an example, I would love to see it. Many thanks in advance.
The Kenerson Group