Hello, I am using the Facebook Nodejs business SDK to pull ad campaigns from a specific ad account. The way I do it is I initialize a new AdAccount using a valid id and then simply use the .getCampaigns method to pull the 'id' and 'name' params. This worked well about a week ago. However, since a few days, I have been getting the following response from the graph API when calling the getCampaigns method:
message: 'An unknown error has occurred.', status: 500, response: { message: 'An unknown error has occurred.', type: 'OAuthException', code: 1,
FYI, I do not think this has something to do with the access token since I am able to perform other operations such as getting ad insights or getting ad accounts.
For more context, here is my function:
async function fetchCampaigns(accountId: string) { const AdAccount = bizSdk.AdAccount; const adAccount = new AdAccount(accountId); let fields, params; fields = [ 'id', 'name', ]; params = { 'effective_status' : ['ACTIVE','PAUSED'], }; try { const campaignsResponse = await adAccount.getCampaigns(fields, params); return campaignsResponse.map((campaign: { id: any; name: any; }) => ({ id: campaign.id, name: campaign.name })); } catch (error) { throw error; } }
This has been resolved, as Meta updated the endpoint to accept an empty data parameter.
Hello, Anyone willing to help?
Hi, I am experiencing the same issue since today
First noticed a very similar issue yesterday.
Oddly, I'm only seeing this with the SDK. I can make queries via the explorer perfectly well. Simply trying to retrieve the name of an act_XXX gives the same error. Taking the URL from the error message and using cURL works just fine.
I have access to two accounts, and get the same behaviour with both. I tried regenerating the tokens, checking permissions and making sure they're valid. The code worked earlier this month.
Update: I replaced the SDK with direct URL fetches the graph API and it works. The SDK seems to be pretty buggy, it regularly just crashes for me if there's an error, I think we'll remove it from our code.
We're seeing the exact same issue. Happy to provide any details here that would be helpful.
For anyone who knows what this means - it's because the SDK is adding a default "data: {}" to the axios' get request.
The minimal reproduction of it is this: curl --location --request GET 'https://graph.facebook.com/v19.0/120203564697850515?fields=status&access_token=XXXX' \ --header 'User-Agent: fbbizsdk-nodejs-v19.0.3' \ --header 'Content-Type: application/json' \ --data '{}'
Where you replace XXXX with your token. Note that typically, GET requests don't get handed that data parameter, and if you remove it, the request succeeds.
I have submitted an issue to the Github repo outlining the problem here: https://github.com/facebook/facebook-nodejs-business-sdk/issues/298
Would be helpful for others to upvote this.