I'm working with the Facebook Graph API v19.0 to update my Facebook Page's address details. According to the documentation, I can use a POST request to the /page_id endpoint with parameters I want to update, like the about section. However, when attempting to update location-related fields (e.g., address, city, zip), my request returns a {"success":true} response, but the page address doesn't update.
I'm using a Page access token with the necessary permissions and setting the Content-Type to application/json.
Could someone clarify how I can update a page's address using the Graph API v19.0? Also, is there a specific JSON structure or additional fields needed for the location update to be processed correctly?
Here's an example of my current JSON payload for reference:
{
"emails": [
"[email protected]"
],
"website": "https://whatsoever.something.com",
"location": {
"zip": "the zipcode",
"street": "the address",
"latitude": 44.800671,
"city_id": "1186314",
"longitude": 10.3314355
},
"contact_address": {
"zip": "the zipcode",
"street1": "the address",
"street2": "",
"city_id": "1186314"
}
}
I have also tried to add city_id field or contact_address, nothing changes. The code I use in Java :
String url = "https://graph.facebook.com/v19.0/" + page_id;
// Create the main JSON object
JSONObject jsonData = new JSONObject();
jsonData.put("about", "Software company");
jsonData.put("email", "Something");
jsonData.put("website", "Something");
// Create a nested JSON object for location
JSONObject location = new JSONObject();;
// Creating a nested location map to structure the JSON correctly
location.put("city", city);
location.put("country", country);
location.put("latitude", latitude);
location.put("longitude", longitude);
location.put("street", address);
location.put("zip", zipCode);
jsonData.put("location", location);
jsonData.put("access_token", page_access_token);
// Prepare the HTTP request with the JSON content type
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Content-Type", "application/json")
.POST(BodyPublishers.ofString(jsonData.toString()))
.build();
HttpClient client = HttpClient.newHttpClient();
try {
// Send the request and receive the response
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
// Process the response
System.out.println("Response Status Code: " + response.statusCode());
System.out.println("Response Body: " + response.body());
} catch (Exception e) {
e.printStackTrace();
}
The response is:
But in my Facebook page I see no changes (Just the Address does not change).
Even if, it is possible to update the address using restFB I would be so thankful to know the code or any hint.
