1

This curl request returns empty square brackets []:

curl "https://www.bathnes.gov.uk/NodeAPI/geoDataLookup/getGeoJSON/-2.8530120849609375/51.263633525637/-2.126541137695313/51.456574106519724/11" -X POST -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/117.0" -H "Accept: application/json, text/javascript, */*; q=0.01" -H "Accept-Language: en-GB,en;q=0.5" -H "Accept-Encoding: gzip, deflate, br" -H "Content-Type: application/json; charset=utf-8" -H "X-Requested-With: XMLHttpRequest" -H "Origin: https://www.bathnes.gov.uk" -H "DNT: 1" -H "Connection: keep-alive" -H "Referer: https://www.bathnes.gov.uk/webforms/planning/" -H "Cookie: banes-cookie-accept=2" -H "Sec-Fetch-Dest: empty" -H "Sec-Fetch-Mode: cors" -H "Sec-Fetch-Site: same-origin" --data-raw "^[""MLYR-54335""^]"

It's obtained from this website:

https://www.bathnes.gov.uk/webforms/planning/#mapSearch

(In Firefox) Press F12 -> Network tab. Press F5 to refresh & look for the only POST method. Right click on it->Copy Value->Copy POST data.

If that POST method is double clicked it returns the expected data in a new tab.

I'm unsure if the headers are required as this returns the same empty brackets:

curl "https://www.bathnes.gov.uk/NodeAPI/geoDataLookup/getGeoJSON/-2.8530120849609375/51.263633525637/-2.126541137695313/51.456574106519724/11" -X POST --data-raw "^[""MLYR-54335""^]"
2
  • 1
    I take it you're on Windows. Are you using CMD or PowerShell? If CMD I don't know why Firefox thinks [ ] in " need ^; they don't, and using it sends invalid JSON which the server apparently doesn't handle. Removing the two ^ makes it work. If PS curl doesn't run the program at all (must be curl.exe instead) and I can't find any syntax that gives valid JSON, though given PS's complexity I expect there is one somewhere. Commented Sep 6, 2023 at 23:37
  • I'm using Win10 & CMD and this resolves my problem. Ta
    – DaveF
    Commented Sep 8, 2023 at 17:41

0

You must log in to answer this question.

Browse other questions tagged .