Skip to content

Admin Location Page APIs

Ravi Sharma edited this page Jun 1, 2014 · 6 revisions

All Ajax apis for Admin Location Page

1. Get Root Location

This api will bring the top location, which will be india in following format

Type : GET

Service End point

/ajax/location/getroot

Response

{
"id": 33132
"name": "India"
"locationTypeId": "1"
"parentLocationId": null
"lattitude": null
"longitude": null
}

2. Get Child Locations

This api will bring the child locations of a parent location identified by parentId,

Type : GET

Service End point

/ajax/location/getchild/{parentId}

For example to bring all child location(States) of a parent location(Country) service will be called like this

/ajax/location/getchild/33132

Response : It will return data in following format

[
   {
      "id":33133,
      "name":"Haryana",
      "locationTypeId":"2",
      "parentLocationId":33132,
      "lattitude":null,
      "longitude":null
   },
   {
      "id":33135,
      "name":"Punjab",
      "locationTypeId":"2",
      "parentLocationId":33132,
      "lattitude":null,
      "longitude":null
   }
]

3. Save Location

This api will save a location

Type : POST

Service End point

/ajax/location/save

Request Payload should be in the following format

{
"name": "kerala",
"parentLocationId": 33132, 
"locationTypeId": 2,  
"lattitude": 14.58,
"longitude": 45.67
}

This will return data in following format

{
   "id":33136,
   "name":"kerala",
   "locationTypeId":"2",
   "parentLocationId":33132,
   "lattitude":14.58,
   "longitude":45.67
}

4. Save Location Type

This api will save a location Type(Hierarchy Node)

Type : POST

Service End point

/ajax/locationtype/save

Request Payload should be in the following format(to create root level node, i.e country)

{
"name": "Country",
"parentLocationTypeId": null
}

Request Payload should be in the following format(to create child level node, i.e state)

{
"name": "State",
"parentLocationTypeId": 1 //Id of country(parent), under which we want to create this node
}

this api will return data in following format

{
"id": "1"
"name": "Country",
"parentLocationTypeId": null
}



{
"id": "2"
"name": "State",
"parentLocationTypeId": "1" 
}

5. To get the full location Type tree

This api will get the full location type tree data

Type : POST

Service End point

/ajax/locationtype/get

Response will be in following format

{
"id":"1"
"name": "Country",
"parentLocationTypeId": null,
"children":[
    {
    "id":"2"
    "name": "State",
    "parentLocationTypeId": "1",
    "children":[
       {
       "id":"3"
       "name": "District",
       "parentLocationTypeId": "2",
       },
      {
       "id":"4"
       "name": "Parliament Constituency",
       "parentLocationTypeId": "2",
       }
     ]
    }
]

}

Clone this wiki locally