ryantxu

Help calling /content/addItem from java

Discussion created by ryantxu on Apr 30, 2013
Latest reply on Jul 18, 2017 by jgrayson-esristaff
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?

Outcomes