Help calling /content/addItem from java

978
2
04-30-2013 01:11 PM
ryanMcKinley
New Contributor
Hello-

I'm trying to post content to ArcGIS Online from a java application using the REST API.  Following:
http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Add_Item/02r30000008q000000/

I have tried many variations of:

  Map<String, String> args = new HashMap<>();
  args.put("url","http://www.mymappingapplication.com");
  args.put("title","My Mapping Application");
  args.put("type","Web Mapping Application");
  args.put("tags","web, mapping, application");
  args.put("token",token.token); // generated from /rest/generateToken
  
  MultipartContent content = new MultipartContent();
  content.addPart(new MultipartContent.Part(new UrlEncodedContent(args)));
  
  System.out.println( "URL>>"+item.toURI() );
  request = requestFactory.buildPostRequest(item, content);
  
  HttpResponse out = request.execute();


The URL is:
http://www.arcgis.com/sharing/rest/content/addItem?f=json

and the response is always:
{"error":{"code":400,"messageCode":"GWM_0001","message":"Specified output format 'json' not supported.","details":[]}}



Any pointers on what I should look into?
0 Kudos
2 Replies
DavidWendelken
Occasional Contributor

Did you ever find a solution?   I ask because I have a similar problem.  Documentation is sparse and, so far, not useful.  

0 Kudos
JohnGrayson
Esri Regular Contributor

Ryan,
   please note that this question was posted to the ArcGIS API for Javascript group.   Regardless, I think you have an incorrect URL as the first part should point to the user content url (<usercontent-url>).  Follow the SDK links to track down the full url:

//<usercontent-url>/addItem
//<content-url>/users/<username>/addItem

//<root-url>/content/users/<username>/addItem

//www.arcgis.com/sharing/rest//content/users/<username>/addItem

Also, since we're dealing with an operation specific to a user I normally use the organization url instead of "www.arcgis".

 

0 Kudos