How to supply line to POST corridor search?

5 posts / 0 new
Last post
marc.christie
How to supply line to POST corridor search?

Hi,

I'm trying to send a compressed line string to the POST corridor search API. I can send a compressed line string to the GET corridor search API with the following:

/search/v2/corridor?key=API_KEY&ambiguities=ignore&hostedData=mqap.API_KEY_test1&line=os%7CrFdiisMou%7CEe%7BqAdqiF%7DqZx%60%7BC%7CeaL&shapeFormat=cmp&maxMatches=5

However, I can't figure out how to format the 'line' parameter for a POST request. I need the POST request because my compressed linestring is too long for the GET request.

Here's what I've tried:

"raw" format as string: POST /search/v2/corridor?key=...&ambiguities=ignore

{
    "hostedDataList": {
        "tableName": "..."
    },
    "line": "39.96488,-76.72995,41.10000,-76.30560",
    "options": {
        "shapeFormat": "raw"
    }
}

 

"simple" WKT format: POST /search/v2/corridor?key=...&ambiguities=ignore

{
    "hostedDataList": {
        "tableName": "..."
    },
    "line": "LINESTRING(-76.305603 40.099998,-76.305603 41.099998,-77.305603 41.099998,-78.305603 39.099998)",
    "options": {
        "shapeFormat": "simple"
    }
}

 

"cmp" compressed linestring: POST /search/v2/corridor?key=...&ambiguities=ignore

{
    "hostedDataList": {
        "tableName": "..."
    },
    "line": "os|rFdiisMou|Ee{qAdqiF}qZx`{C|eaL",
    "options": {
        "shapeFormat": "cmp"
    }
}

 

"raw" format as array of lat/longs: POST /search/v2/corridor?key=...&ambiguities=ignore

{
    "hostedDataList": {
        "tableName": "..."
    },
    "line": [
        28.326345,
        -82.321754,
        28.873645,
        -82.095207
    ],
    "options": {
        "shapeFormat": "raw"
    }
}

(This matches the format of the example request body in the documentation of the POST corridor search API: https://developer.mapquest.com/documentation/search-api/v2/corridor-sear... although strictly speaking this format, using an array, isn't specified on the LineString geometry documentation page: https://developer.mapquest.com/documentation/search-api/v2/geometry/)

 

For all of these requests I get the same error:

{
    "info": {
        "copyright": {
            "imageAltText": "\u00a9 2019 MapQuest, Inc.",
            "imageUrl": "http://api.mqcdn.com/res/mqlogo.gif",
            "text": "\u00a9 2019 MapQuest, Inc."
        },
        "messages": [
            "Session Id or Corridor passed are not valid!"
        ],
        "statusCode": 680
    }
}

 

Oddly, even passing a sessionId fails, although it works for the GET request. Here's my sessionId request:

POST /search/v2/corridor?key=...&ambiguities=ignore

{
    "hostedDataList": {
        "tableName": "..."
    },
    "sessionId": "5cc5d79d-0165-6750-02b4-19a8-0ef0814c076c"
}

Response:

{
    "info": {
        "copyright": {
            "imageAltText": "\u00a9 2019 MapQuest, Inc.",
            "imageUrl": "http://api.mqcdn.com/res/mqlogo.gif",
            "text": "\u00a9 2019 MapQuest, Inc."
        },
        "messages": [
            "Session Id or Corridor passed are not valid!"
        ],
        "statusCode": 680
    }
}

 

So in summary, I can't get a POST corridor search to work and specifically I want to know how to format a request with a compressed line string. Are there code samples or more explicit documentation on how to form such a request?

 

Thanks,

Marcus


MQBrianCoakley
I did this route: 

I did this route: 

http://www.mapquestapi.com/directions/v2/route?key=KEY&shapeFormat=cmp&generalize=0&from=1555%20Blake%20St%2C%20Denver%2C%20CO%20%2080202&to=555%2017th%20St%2C%20Denver%2C%20CO%20%2080202

 

and used the shape result in this search POST body: 

{"line": "avrqFbvz_S`BfC@@NZVV\b@rBnC??`Ai@RQNKHITUXc@f@s@Xc@j@y@T]bAuA~@uA??y@iAqAmBOS]e@[c@wCeEaDiE]g@??pAmBb@i@T[~BsD`AqAfAwA|@wA~@uABEdAsAbAqAFIz@mAbAuA`AuAZc@","options":{"maxMatches":3,"shapeFormat":"cmp"}}

 

and it returns the expected results.


marc.christie
Thanks Brian. Turns out the

Thanks Brian. Turns out the problem was that I had the ambiguities argument set to ignore in the corridor search request. Removing it and POSTing to /search/v2/corridor?key=KEY worked.

 

 


MQBrianCoakley
Good to hear you got it
Good to hear you got it working. I missed the ambiguities part.

marc.christie
Also, I realized I was

Also, I realized I was formatting "hostedDataList" incorrectly and that it should be an array. So now my request body is like

{
    "hostedDataList": [{
        "tableName": "..."
    }],
    "line": "os|rFdiisMou|Ee{qAdqiF}qZx`{C|eaL",
    "options": {
        "shapeFormat": "cmp"
    }
}