Unable to update ad creative URL through graph API
1

I'm trying to update the URL of a carousel ad using graph API. The API response shows a success status, but the URL doesn't get updated. Using the following service to update the URL. using System; using System.Net.Http; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json;

public class FacebookAdCreativeUpdater { private static readonly string accessToken = "your_access_token"; private static readonly string adCreativeId = "your_adcreative_id";

public static async Task UpdateChildAttachmentUrlAsync()
{
    // Define the new URL and include name in the payload for updating the ad creative
    var updatedObjectStorySpec = new
    {
        name = "Updated Ad Creative Name", // Required field
        object_story_spec = new
        {
            page_id = "your_page_id",
            link_data = new
            {
                link = "https://new-main-url.com",
                child_attachments = new[]
                {
                    new { link = "https://updated-child-url-1.com" }, // First child attachment
                    new { link = "https://existing-child-url-2.com" }  // Second child attachment
                }
            }
        }
    };

    // Convert the object to JSON
    string jsonContent = JsonConvert.SerializeObject(updatedObjectStorySpec);
    StringContent content = new StringContent(jsonContent, Encoding.UTF8, "application/json");

    // Define the URL for updating the ad creative
    string url = $"https://graph.facebook.com/v13.0/{adCreativeId}?access_token={accessToken}";

    using HttpClient client = new HttpClient();
    HttpResponseMessage response = await client.PostAsync(url, content);

    if (response.IsSuccessStatusCode)
    {
        string result = await response.Content.ReadAsStringAsync();
        Console.WriteLine("Child attachment URL updated successfully:");
        Console.WriteLine(result);
    }
    else
    {
        string error = await response.Content.ReadAsStringAsync();
        Console.WriteLine($"Error updating child attachment URL: {error}");
    }
}

public static void Main(string[] args)
{
    UpdateChildAttachmentUrlAsync().Wait();
}

}

Indu
Enviada na terça