I am trying to convert
curl -d '[[51.3, 13.4], [51.4, 13.3]]' -XPOST -H 'Content-Type: application/json' https://elevation.racemap.com/api
Curl command into Python. I tried
import urllib.request
import json
body = {'locs': [[51.3, 13.4], [51.4, 13.3]]}
myurl = "https://elevation.racemap.com/api"
req = urllib.request.Request(myurl)
req.add_header('Content-Type', 'application/json; charset=utf-8')
jsondata = json.dumps(body)
jsondataasbytes = jsondata.encode('utf-8')
req.add_header('Content-Length', len(jsondataasbytes))
print (jsondataasbytes)
response = urllib.request.urlopen(req, jsondataasbytes)
which gives an error. It seems curl does not specify parameter name while passing an array? I am not sure how to form the Json to fit the curl input.