0

I would like to get latitude and longitude from a batch address list with the help of HERE batch geocoding api. Could you help me send the file "addresses.txt" via POST? I tried the command in linux mint and received "Error 400". :'(

wget --header="Content-Type: text/plain; charset=UTF-8" --post-file=addresses.txt"https://batch.geocoder.api.here.com/6.2/jobs?&app_code=xxxxx&app_id=xxxxxxx&action=run&header=true&inDelim=;&outDelim=,&outCols=recId,latitude,longitude,locationLabel&mailto=xxxxxxx&outputcombined=true&language=pt-BR"

My text file contains only addresses, no headers, and each line represents a different address, In total, 30,000 lines.

Example:

street of the apple, 01, center, são paulo-SP
street of orange, 15, center, são paulo-SP

It can be another alternative "cmd", "shell windows". Thank you!

1 Answers1

0

A 400 means that the request was malformed. In other words, the data stream sent by the client to the server didn't follow the rules. In the case of a REST API with a JSON payload, 400's are typically, and correctly I would say, used to indicate that the JSON is invalid in some way according to the API specification for the service.

the address data can be structured (qualified) or unstructured (freeform). The following is an example of an input file with free-form addresses with a country code qualifier using "|" as a delimiter. The first line is a header that lists the names of the columns in the input file. The following is an example of the same addresses in fully qualified form: The column recId is optional. If provided, it is repeated in the output for reference. If you have an occurrence of the delimiter character in the data, you must enclose the data in double quotes. The example below illustrates a case where the delimiter is a comma and the input contains commas. A single double quote (") per input line is regarded as a regular character. The following example shows a correct input line. In comparison, the example shown below is invalid. There is no end quote, resulting in four instead of the three fields per input line the service expects.

recId|searchText|country 1|425 W Randolph St, Chicago Illinois 60606|USA 2|31 St James Ave Boston MA 02116|USA 3|10115 Berlin Invalidenstrasse 117|DEU

recId|street|city|postalCode|country 1|425 Randolph St|Chicago||USA 2|31 St James Ave|Boston|02116|USA 3|Invalidenstrasse 117|Berlin|10115|DEU

recId,searchText,country 1,"Sturmstraße 8, 80687 München", DEU 2,"Milano", ITA 3,"Rom", ITA 4,"Tecklenburger Straße, Westerkappeln 49492", DEU 5,"425 W Randolph St Chicago, Illinois, 60606", USA

recId,searchText,country 1,O"Farell St San Francisco,USA

recId,searchText,country 1,"Sturmstraße 8, 80687 München,DEU

Dummy address.txt $ cat address.txt recId,searchText,country 1,"Sturmstraße 8, 80687 München", DEU 2,"Milano", ITA 3,"Rom", ITA 4,"Tecklenburger Straße, Westerkappeln 49492", DEU 5,"425 W Randolph St Chicago, Illinois, 60606", USA

wget --header="Content-Type: text/plain; charset=UTF-8" --post-file=address.txt "https://batch.geocoder.api.here.com/6.2/jobs?&app_code=xxxxxxx&app_id=xxxxxxx&action=run&header=true&inDelim=,&outDelim=,&outCols=recId,latitude,longitude,locationLabel&mailto=xyz@gmail.com&outputcombined=true&language=de-DE"

--2019-03-14 15:12:02-- https://batch.geocoder.api.here.com/6.2/jobs?&app_code=xxxx&app_id=xxxxx&action=run&header=true&inDelim=,&outDelim=,&outCols=recId,latitude,longitude,locationLabel&mailto=xyz@gmail.com&outputcombined=true&language=de-DE Resolving batch.geocoder.api.here.com (batch.geocoder.api.here.com)... 52.33.227.75, 52.35.120.176 Connecting to batch.geocoder.api.here.com (batch.geocoder.api.here.com)|52.33.227.75|:443... connected. HTTP request sent, awaiting response... 200 Length: 468 [application/xml] Saving to: 'jobs?&app_code=xxxx&app_id=xxxxxx&action=run&header=true&inDelim=,&outDelim=,&outCols=recId,latitude,longitude,locationLabel&mailto=xyz@gmail.com&outputcombined=true&language=de-DE'

jobs?&app_code=xxx&app_id=xxxx 100%[=========================================================================================================================================>] 468 --.-KB/s in 0s

2019-03-14 15:12:04 (26.3 MB/s) - 'jobs?&app_code=xxxx&app_id=xxxxx&action=run&header=true&inDelim=,&outDelim=,&outCols=recId,latitude,longitude,locationLabel&mailto=xyz@gmail.com&outputcombined=true&language=de-DE' saved [468/468]