For most of the cases, when specifying full location name, the search by the location parameter should work fine.
However sometimes search by location may not give you what you expect, as LinkedIn have some other location for your text query.
For example, NY returns New Zealand as first match instead of New York
(it’s based on LinkedIn autocomplete feature, you can try it in UI).
To make sure the location is correct, you can fetch LinkedIn GeoID first and check it.
GeoID search is free, it will not count against your quota.
const apiKey ='<api-key>';fetch(`https://api.harvest-api.com/linkedin/geo-id-search?search=New York`,{headers:{'X-API-Key': apiKey },}).then((response)=> response.json()).then((data)=>{console.log('All matches:', data.elements);console.log('Closest match GeoID:', data.id);// Search for profiles in New Yorkconst params =newURLSearchParams({geoId: data.id, apiKey,});fetch(`https://api.harvest-api.com/linkedin/profile-search?${params.toString()}`).then((response)=> response.json()).then((data)=>console.log(data));});