When creating adsets using Facebook Graph API getting error?

61 Views Asked by At

I have been working with Meta APIs with laravel guzzle and whenever i use APIs for adsets for creating,i am getting error code 2490027 response not able to create adset for an ad campaign.

Error :

message : Invalid parameter type : OAuthException code : 100 error_subcode : 2490027 is_transient : false

    $url="https://graph.facebook.com/v18.0/act_".$ad_account_id."/adsets";

    $this->create_fb_user_access($user_id);

    $client = new \GuzzleHttp\Client();

    $adset_data = [
        'name' => 'Your Ad Set Name',
        'campaign_id' => $campaign_id,
        'targeting' => [
            'geo_locations' => [
                'countries' => ['IN'],
            ],
        ],
        'billing_event' => 'IMPRESSIONS',
    ];


    try {
        // Make a POST request to create the Ad Set

        $response = $client->post($url, [
            'headers' => [
                'Content-Type' => 'application/json',
            ],
            'query' => [
                'access_token' => $this->userAccessToken,
            ],
            'json' => $adset_data,
        ]);

        $data = json_decode($response->getBody()->getContents(), true);

        return $data['id'];
    } catch (\Exception $e) {
        // Handle exceptions
        dd($e->getMessage());
    }
}`

What is this Error? How can i correct this error?

Thank You.

0

There are 0 best solutions below