Search code examples
mapquest

How to post data to a mapquest table


I'm trying to post data to a mapquest table and I've done everything according to their API

Here is my json:

{
    "tableName": "mqap.jZ3uoAVablablabla_reported_points",
    "append": true,
    "returnResults": true, 
    "rows": [
        [
            {
                "mqap_geography": "POINT (-123.3141509 48.4647675)",
                "date": "2016-03-13T02:19:09.674Z",
                "email": "anna@gmail.com",
                "latitude": "48.47542496514236",
                "longitude": "-123.37663650512695",
                "message": "ss",
                "user": "a"
            }
        ]
    ]

}

Here is a screenshot of the table

enter image description here

And this is the response I get in Postman

{
  "failures": [
    {
      "reason": "Either no latitude/longitude was provided, or the other information was insufficient for geocoding at or near line #0 of input.",
      "row": ""
    }
  ],
  "append": true,
  "returnResults": true,
  "totalRows": 1,
  "tableName": "mqap.jblablabla_reported_points",
  "tableSize": {
    "raw": 8192,
    "readable": "8 KB"
  },
  "data": {
    "rows": []
  },
  "failureCount": 1,
  "rowCount": 0,
  "info": {
    "statusCode": 0,
    "copyright": {
      "text": "© 2015 MapQuest, Inc.",
      "imageUrl": "http://api.mqcdn.com/res/mqlogo.gif",
      "imageAltText": "© 2015 MapQuest, Inc."
    },
    "messages": []
  }
}

What am I doing wrong?


Solution

  • Two things I was missing:

    1. The database NEEDS to have a geography object. So I added a latlong Geography object that I didn't end up using.
    2. The format of the JSON should've been the following:

      {
      "tableName": "mqap.jZ3uoAVablablabla_reported_points",
      "append": true,
      "returnResults": true, 
      "rows": [
             [
             {"name":"user","value":user},
             {"name":"email","value":email},
             {"name":"date","value":date},
             {"name":"message","value":message},
             {"name":"latitude","value":latitude},
             {"name":"longitude","value"longitude},
             {"name":"latlong","value":"POINT(" + parseFloat(longitude) + " " + parseFloat(latitude) +")"}
             ]
          ]
      }