arcgis token 调用token生成接口,生成报错

在c#后台通过webrequest 调用arcgis server10.2的token生成接口http://ip:6080/arcgis/tokens/generateToken,生成token时报错  "invalid credentials"
7C69978D66D8E5D18B5A3B1808D7F706.png

怎么解决?ps:需要通过c#后台代码调用的方式。
 
已邀请:

许丹石 - Esri技术支持工程师

赞同来自:

不懂C#有java调portal generateToken接口的,你参考下:
    public String getToken() {
String tokenjson ="";
String url = portalUrl+"generateToken";
String param ="";
StringBuffer buffer = new StringBuffer();
buffer.append("------footfoodapplicationrequestnetwork\r\n");
buffer.append("Content-Disposition: form-data; name=\"");
buffer.append("username");
buffer.append("\"\r\n\r\n");
buffer.append(name);
buffer.append("\r\n");
buffer.append("------footfoodapplicationrequestnetwork\r\n");
buffer.append("Content-Disposition: form-data; name=\"");
buffer.append("password");
buffer.append("\"\r\n\r\n");
buffer.append(password);
buffer.append("\r\n");
buffer.append("------footfoodapplicationrequestnetwork\r\n");
buffer.append("Content-Disposition: form-data; name=\"");
buffer.append("client");
buffer.append("\"\r\n\r\n");
buffer.append("requestip");
buffer.append("\r\n");
buffer.append("------footfoodapplicationrequestnetwork\r\n");
buffer.append("Content-Disposition: form-data; name=\"");
buffer.append("expiration");
buffer.append("\"\r\n\r\n");
buffer.append("60");
buffer.append("\r\n");
buffer.append("------footfoodapplicationrequestnetwork\r\n");
buffer.append("Content-Disposition: form-data; name=\"");
buffer.append("f");
buffer.append("\"\r\n\r\n");
buffer.append("json");
buffer.append("\r\n");
buffer.append("------footfoodapplicationrequestnetwork--\r\n");
param=buffer.toString();
try {
tokenjson=httpSender.sendPost(url,param);
} catch (Exception e) {
e.printStackTrace();
}
HashMap hashMap= new HashMap<String,String>();
String token ="";
if(tokenjson!=null&&!"".equals(tokenjson)){
token=tokenjson.substring(10,tokenjson.indexOf("expires")-3);
}
return token;
}

要回复问题请先登录注册