Select to view content in your preferred language

Publish a service with detailed parameters FAILS

1262
5
07-27-2017 02:48 PM
NareshAligeti2
Emerging Contributor

I used this script as-is with some changes to the below variables,

username = raw_input("Enter user name: ")

password = getpass.getpass("Enter password: ")

# Ask for other necessary information

serverName = raw_input("Enter Server name: ")

serverPort = 6080

mxdPath = raw_input("Enter the path to the MXD: ")

msdPath = raw_input("Enter the desired path for the MSD: ")

jsonPath = raw_input("Enter the path to the JSON file: ")

I keep getting the below error, not sure what's wrong.

---> Error: JSON object returns an error. {u'status': u'error', u'code': 500, u'messa
ges': [u"JSON object for 'Service' is missing required attribute 'type'"]}
Error returned by operation. {"status":"error","messages":["JSON object for 'Ser
vice' is missing required attribute 'type'"],"code":500}

Could someone help? Thanks.

0 Kudos
5 Replies
RandyBurton
MVP Alum

Can you post your json file?  The error indicates it is missing the type parameter.  There is a sample json file on the page you referenced.  According to the sample, the type should be something like:

"type": "MapServer"
0 Kudos
NareshAligeti2
Emerging Contributor

Here it is. I dont see anything wrong with "Type"

{

  • "folderName" : Geocortex,
  • "service" : -{
    • "serviceName" : Service_Area,
    • "type" : MapServer,
    • "description" : ,
    • "capabilities" : Map,Query,Data,
    • "properties" : -{
      • "virtualCacheDir" : /rest/directories/arcgiscache,
      • "maxImageHeight" : 4096,
      • "exportTilesAllowed" : false,
      • "textAntialiasingMode" : None,
      • "maxImageWidth" : 4096,
      • "enableDynamicLayers" : false,
      • "dynamicDataWorkspaces" : ,
      • "supportedImageReturnTypes" : URL,
      • "disableIdentifyRelates" : false,
      • "isCached" : false,
      • "maxScale" : 4513.9887049999998,
      • "maxBufferCount" : 100,
      • "schemaLockingEnabled" : false,
      • "maxRecordCount" : 1000,
      • "cacheDir" : \\\\somethinng\\AGS_1031\\DEV\\DEV02\\arcgisserver\\directories\\arcgiscache,
      • "cacheOnDemand" : false,
      • "useLocalCacheDir" : true,
      • "virtualOutputDir" : /rest/directories/arcgisoutput,
      • "outputDir" : \\\\somethinng\\AGS_1031\\DEV\\DEV02\\arcgisserver\\directories\\arcgisoutput,
      • "minScale" : 9244648.8686180003,
      • "maxDomainCodeCount" : 25000,
      • "maxExportTilesCount" : 100000,
      • "ignoreCache" : false,
      • "antialiasingMode" : None,
      • "clientCachingAllowed" : true,
      • "filePath" : \\\\somethinng\\AGS_1031\\DEV\\DEV02\\arcgisserver\\directories\\arcgissystem\\arcgisinput\\Geocortex\\Service_Area.MapServer\\extracted\\v101\\Service_Area.msd
      },
    • "clusterName" : default,
    • "maxIdleTime" : 1800,
    • "isolationLevel" : HIGH,
    • "loadBalancing" : ROUND_ROBIN,
    • "configuredState" : STARTED,
    • "minInstancesPerNode" : 1,
    • "maxInstancesPerNode" : 2,
    • "maxWaitTime" : 60,
    • "maxUsageTime" : 600,
    • "instancesPerContainer" : 1,
    • "keepAliveInterval" : 1800,
    • "recycleStartTime" : 00:00,
    • "recycleInterval" : 24,
    • "extensions" : -[
      • -{
        • "enabled" : false,
        • "typeName" : KmlServer,
        • "capabilities" : SingleImage,SeparateImages,Vectors,
        • "properties" : -{
          • "message" : ,
          • "minRefreshPeriod" : 30,
          • "linkDescription" : ,
          • "useNetworkLinkControlTag" : false,
          • "compatibilityMode" : GoogleEarth,
          • "imageSize" : 1024,
          • "dpi" : 96,
          • "endPointURL" : ,
          • "linkName" : ,
          • "composite" : true,
          • "featureLimit" : 1000000,
          • "useDefaultSnippets" : false
          }
        },
      • -{
        • "enabled" : false,
        • "typeName" : WMSServer,
        • "capabilities" : GetCapabilities,GetMap,GetFeatureInfo,GetStyles,GetLegendGraphic,GetSchemaExtension,
        • "properties" : -{
          • "abstract" : ,
          • "onlineResource" : http://organization.com:6080/arcgis/services/Geocortex/Service_Area/MapServer/WMSServer,
          • "keyword" : ,
          • "postCode" : ,
          • "inheritLayerNames" : false,
          • "contactPosition" : ,
          • "fees" : ,
          • "addressType" : ,
          • "contactVoiceTelephone" : ,
          • "pathToCustomSLDFile" : ,
          • "country" : ,
          • "city" : ,
          • "contactFacsimileTelephone" : ,
          • "title" : ,
          • "contactOrganization" : ,
          • "address" : ,
          • "contactElectronicMailAddress" : ,
          • "customGetCapabilities" : false,
          • "name" : WMS,
          • "stateOrProvince" : ,
          • "pathToCustomGetCapabilitiesFiles" : ,
          • "accessConstraints" : ,
          • "contactPerson" : 
          }
        },
      • -{
        • "enabled" : false,
        • "typeName" : ArcFMMapServer,
        • "capabilities" : Query,Trace,
        • "properties" : -{
            }
          },
        • -{
          • "enabled" : false,
          • "typeName" : NAServer,
          • "capabilities" : ,
          • "properties" : -{
            • "oDCostMatrix_MaxDestinationsToFind" : ,
            • "serviceArea_MaxBreakValue_TimeUnits" : esriTimeUnitsMinutes,
            • "vRP_MaxFeaturesInPolygonBarriers" : ,
            • "vRP_MaxRoutes" : ,
            • "serviceArea_MaxBarriers" : ,
            • "route_MaxFeaturesInLineBarriers" : ,
            • "locationAllocation_MaxDemandPoints" : ,
            • "vRP_ForceHierarchyBeyondDistanceUnits" : esriMeters,
            • "route_ForceHierarchyBeyondDistanceUnits" : esriMeters,
            • "closestFacility_MaxFeaturesInPolygonBarriers" : ,
            • "closestFacility_MaxFacilities" : ,
            • "oDCostMatrix_MaxDestinations" : ,
            • "serviceArea_MaxBreakValue_Length" : ,
            • "serviceArea_ForceHierarchyBeyondTimeUnits" : esriTimeUnitsMinutes,
            • "serviceArea_ForceHierarchyBeyondDistanceUnits" : esriMeters,
            • "vRP_MaxFeaturesInLineBarriers" : ,
            • "closestFacility_ForceHierarchyBeyondDistanceUnits" : esriMeters,
            • "route_AllowTimeWindows" : true,
            • "serviceArea_MaxFacilities" : ,
            • "locationAllocation_MaxFeaturesInPolygonBarriers" : ,
            • "oDCostMatrix_MaxFeaturesInLineBarriers" : ,
            • "route_MaxFeaturesInPolygonBarriers" : ,
            • "locationAllocation_ForceHierarchyBeyondDistance" : ,
            • "saveLayerOnServerWhenError" : false,
            • "route_ForceHierarchyBeyondDistance" : ,
            • "locationAllocation_ForceHierarchyBeyondDistanceUnits" : esriMeters,
            • "serviceArea_ForceHierarchyBeyondTime" : ,
            • "route_MaxStops" : ,
            • "serviceArea_MaxFeaturesInLineBarriers" : ,
            • "closestFacility_MaxIncidents" : ,
            • "allowSaveLayerOnServer" : true,
            • "oDCostMatrix_ForceHierarchyBeyondDistanceUnits" : esriMeters,
            • "route_MaxBarriers" : ,
            • "vRP_MaxBarriers" : ,
            • "serviceArea_MaxBreakValue_LengthUnits" : esriMeters,
            • "oDCostMatrix_ForceHierarchyBeyondDistance" : ,
            • "serviceArea_ForceHierarchyBeyondDistance" : ,
            • "saveLayerOnServerWhenDebugging" : false,
            • "closestFacility_MaxFeaturesInLineBarriers" : ,
            • "oDCostMatrix_MaxFeaturesInPolygonBarriers" : ,
            • "oDCostMatrix_MaxBarriers" : ,
            • "closestFacility_MaxFacilitiesToFind" : ,
            • "closestFacility_MaxBarriers" : ,
            • "serviceArea_MaxBreakValue_Other" : ,
            • "defaultOutputGeometryPrecisionUnits" : esriMeters,
            • "vRP_ForceHierarchyBeyondDistance" : ,
            • "naLayerDir" : ,
            • "oDCostMatrix_MaxOrigins" : ,
            • "locationAllocation_MaxBarriers" : ,
            • "locationAllocation_MaxFeaturesInLineBarriers" : ,
            • "closestFacility_ForceHierarchyBeyondDistance" : ,
            • "vRP_MaxOrders" : ,
            • "serviceArea_ForceHierarchyBeyondOther" : ,
            • "defaultOutputGeometryPrecision" : ,
            • "serviceArea_MaxFeaturesInPolygonBarriers" : ,
            • "serviceArea_MaxBreakValue_Time" : ,
            • "locationAllocation_MaxFacilities" : 
            }
          },
        • -{
          • "enabled" : false,
          • "typeName" : SchematicsServer,
          • "capabilities" : Query,
          • "properties" : -{
            • "supportsREST" : true
            }
          },
        • -{
          • "enabled" : false,
          • "typeName" : WCSServer,
          • "capabilities" : ,
          • "properties" : -{
            • "phone" : ,
            • "maxImageHeight" : ,
            • "maxImageWidth" : ,
            • "city" : ,
            • "providerWebsite" : ,
            • "title" : ,
            • "name" : Service_Area,
            • "customGetCapabilities" : ,
            • "province" : ,
            • "role" : ,
            • "accessConstraints" : ,
            • "abstract" : ,
            • "onlineResource" : http://organization.com:6080/arcgis/services/Geocortex/Service_Area/MapServer/WCSServer,
            • "keywords" : ,
            • "fax" : ,
            • "zipcode" : ,
            • "fees" : ,
            • "country" : ,
            • "responsiblePerson" : ,
            • "providerName" : ,
            • "responsiblePosition" : ,
            • "email" : ,
            • "address" : ,
            • "pathToCustomGetCapabilitiesFiles" : ,
            • "contactInstructions" : ,
            • "serviceHour" : 
            }
          },
        • -{
          • "enabled" : false,
          • "typeName" : FeatureServer,
          • "capabilities" : Query,Create,Update,Delete,Uploads,Editing,
          • "properties" : -{
            • "creatorPresent" : false,
            • "dataInGdb" : true,
            • "xssPreventionEnabled" : true,
            • "allowGeometryUpdates" : true,
            • "maxRecordCount" : 1000,
            • "allowOthersToQuery" : true,
            • "syncEnabled" : false,
            • "editorTrackingTimeZoneID" : UTC,
            • "enableZDefaults" : false,
            • "realm" : ,
            • "allowTrueCurvesUpdates" : false,
            • "allowOthersToDelete" : false,
            • "datasetInspected" : true,
            • "editorTrackingRespectsDayLightSavingTime" : false,
            • "zDefaultValue" : 0,
            • "editorTrackingTimeInUTC" : true,
            • "enableOwnershipBasedAccessControl" : false,
            • "allowOthersToUpdate" : false
            }
          },
        • -{
          • "enabled" : false,
          • "typeName" : WFSServer,
          • "capabilities" : ,
          • "properties" : -{}
          },
        • -{
          • "enabled" : false,
          • "typeName" : MobileServer,
          • "capabilities" : Uploads,
          • "properties" : -{
              }
            }
          ],
        • "provider" : ArcObjects
        }

      }

      0 Kudos
      RandyBurton
      MVP Alum

      After a quick look, Map Server - and the other string values - should be quoted:  "Map Server".  I would suggest using a service like jsonlint.com to verify that your json is properly formatted.  See JSON Data Types (and related pages at w3schools.com) for some additional information on formatting numbers, booleans, arrays,  and nulls.

      0 Kudos
      NareshAligeti2
      Emerging Contributor

      They are all quoted. Its just how the code was pasted. I did revalidate my JSON and it looks just fine. 

      0 Kudos
      VidmasKondratas
      Esri Contributor

      This is an older post but I ran into a similar problem just now with the ArcGIS Server 11.3 REST API. It looks like you copied the JSON data form the server services directory, which wasn't the correct format for the REST API in my case. I needed to remove the "folderName" and "service" JSON objects  from {"folderName" : Geocortex,"service" : {"serviceName" : Service_Area,... and begin the JSON file with the {"serviceName" : Service_Area,... portion. Then my JSON published with the REST API. 

      0 Kudos