I trying to build my develop environment to test the facebook marketing api.
I have created campaigns and adset and ads as drafts and when
I Try to get it as draft I'am using this endpoint
act_xxxx/campaigns/?include_drafts=true
But I getting this error :
"error": {
"message": "(#100) Param include_drafts on field campaigns: This param is not valid",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "AdxtFrxBwJ0pCeYMxKHBkqC" }
IN facebook doc https://developers.facebook.com/docs/marketing-api/reference/ad-account/campaigns
There is available this parameter.
When I tried with the python SDK I'm getting the same error:
listEffectiveStatus = [
Campaign.EffectiveStatus.paused,
Campaign.EffectiveStatus.active,
Campaign.EffectiveStatus.archived,
Campaign.EffectiveStatus.in_process,
Campaign.EffectiveStatus.with_issues
]
paramCamping = {
'effective_status': listEffectiveStatus,
'include_drafts': True,
'use_employee_draft': True}
campaigns = my_account.get_campaigns(fields=fieldsCampaigns, params=paramCamping )
Someone could help me with this problem? Or know some solution.
Related
I am using JIRA python api to update JIRA
I need to update customfield_10800 field.
below is the code i used
updatedict = {
"customfield_10800":
{ "id": "485",
"title": "Facilities IT", "isShared": True
}
}
self.jira = self.LogInJira()
issue = self.jira.issue(jiraid)
issue.update(fields=updatedict)
self.jira.transition_issue(jiraid, transition=jid)
I am getting the following error
response text = {"errorMessages":[],"errors":{"customfield_10800":"The Team must be a string"}}
can you help to solve
Lately, the Facebook Marketing API throws an OAuthException error with code 100/missing permissions. When looking into the Facebook Developer App, nothing indicates that the permissions are missing or not configured properly. The permissions needed for the Insights API (ads_read) is active and currently at Standard Access (which should be sufficient).
I've also validated my token with the Access Token debugger, but it's valid nonetheless. I am using the Python facebook-business SDK 12.0.1 to make the call to the Insights endpoint:
params = {
'time_range': {'since' : self.time_range, 'until' : self.time_range},
'breakdowns' : self.breakdowns,
'fields': self.fields,
'filtering' : self.filtering,
'level': self.level,
'limit' : self.limit
}
response = my_account.get_insights(params=params)
The full error code:
Message: Call was not successful
Method: GET
Path: https://graph.facebook.com/v12.0/{ad_account_id}/insights
Params: {'time_range': '{"since":"2021-10-28","until":"2021-10-28"}', 'breakdowns': '["publisher_platform","platform_position"]', 'fields': '["campaign_name","clicks","spend","impressions","date_start","campaign_id","adset_id","ad_id","adset_name","ad_name","link_url"]', 'filtering': '[{"field":"ad.impressions","operator":"GREATER_THAN","value":"0"}]', 'level': 'ad', 'limit': '100000'}
Status: 400
Response:
{
"error": {
"message": "(#100) Missing permissions",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "AZhZZ3O_3iRkR4nObcyU-yB"
}
}
My current assumption is that something is wrong with the FB Marketing API. Or is it?
I had this same problem. I found this helpful re: the access token.
https://github.com/fbsamples/messenger-platform-samples/issues/125
In my case I needed to use the PAGE_ACCESS_TOKEN instead of the access_token acquired by hitting "https://graph.facebook.com/oauth/access_token?client_id=<app_id>&client_secret=<app_secret>&grant_type=client_credentials"
Of course this is clear as mud in facebook's documentation.
I'm trying to make a data partition refresh (post) following this azure documentation : https://learn.microsoft.com/en-us/azure/analysis-services/analysis-services-async-refresh
Either with post or get I got 401 Unauthorized (Even when the service is Off !).
I got the token from azure AD (ServicePrincipalCredential).
I added the AD as Analysis Services Admins (https://learn.microsoft.com/en-us/azure/analysis-services/analysis-services-server-admins)
I gave the owner role to AD in Analysis Services IAM.
it worked with Analysis Services management rest api (https://learn.microsoft.com/en-us/rest/api/analysisservices/operations/list) With the same authentification (got code response 200)
My python code :
from azure.common.credentials import ServicePrincipalCredentials
import requests
credentials = ServicePrincipalCredentials(client_id="ad_client_id",
secret="ad_secret",
tenant="ad_tenant")
token = credentials.token
url = "https://westeurope.asazure.windows.net/servers/{my_server}/models/{my_model}/refreshes"
test_refresh = {
"Type": "Full",
"CommitMode": "transactional",
"MaxParallelism": 1,
"RetryCount": 1,
"Objects": [
{
"table": "my_table",
"partition": "my_partition"
}
]
}
header={'Content-Type':'application/json', 'Authorization': "Bearer {}".format(token['access_token'])}
r = requests.post(url=url, headers=header, data=test_refresh)
import json
print(json.dumps(r.json(), indent=" "))
Response I got :
{
"code": "Unauthorized",
"subCode": 0,
"message": "Authentication failed.",
"timeStamp": "2019-05-22T13:39:03.0322998Z",
"httpStatusCode": 401,
"details": [
{
"code": "RootActivityId",
"message": "aab22348-9ba7-42c9-a317-fbc231832f75"
}
]
}
I'm hopeless, could you please give me somes help to make this clear ?
Finally I resolved the issue.
I had wrong token. The api expect an OAuth2.0 authentification token (The Azure analysis services rest api documentation ins't very clear about the way to get one)
For thoses will encounter the same issu there is the way to get one.
from adal import AuthenticationContext
authority = "https://login.windows.net/{AD_tenant_ID}"
auth_context = AuthenticationContext(authority)
oauth_token = auth_context.acquire_token_with_client_credentials(resource="https://westeurope.asazure.windows.net", client_id=AD_client_id, client_secret=AD_client_id)
token = oauth_token['accessToken']
Documentation about this :
https://learn.microsoft.com/en-us/python/api/adal/adal.authentication_context.authenticationcontext?view=azure-python#acquire-token-with-client-credentials-resource--client-id--client-secret-
https://github.com/AzureAD/azure-activedirectory-library-for-python/wiki/ADAL-basics
Most likely your token is not right.
Have you tried validating your token? Use something like http://calebb.net/
I see some examples of ServicePrincipalCredentials that stipulate the context or resource like this:
credentials = ServicePrincipalCredentials(
tenant=options['tenant_id'],
client_id=options['script_service_principal_client_id'],
secret=options['script_service_principal_secret'],
resource='https://graph.windows.net'
Good samples here:
https://www.programcreek.com/python/example/103446/azure.common.credentials.ServicePrincipalCredentials
I think the solution is try a couple more things that make sense and follow the error details.
You need token which has resource (audience) set to https://*.asazure.windows.net
For token validation I like https://jwt.io
Also if you want to automate this properly you have two options
Either by Logic Apps
or with Azure Data Factory
Both of which I have very detailed posts on if you want to check them out
https://marczak.io/posts/2019/06/logic-apps-refresh-analysis-services/
https://marczak.io/posts/2019/06/logic-app-vs-data-factory-for-aas-refresh/
I am trying to get the list of followers via Instagram API.
At the process, Instagram API does not give me a key of pagination as follows.
I'm at Sandbox mode and creating the app for passing the review of Instagram API. Also tried to get data directly via Python library but still does not work.
Could you tell me how to get a key of pagination?
from instagram.client import InstagramAPI
access_token = "ACCESS_TOKEN"
client_secret = "CLIENT_SECRET"
api = InstagramAPI(access_token=access_token, client_secret=client_secret)
followed_by, next = api.user_followed_by()
print next # -> None
# 'pagination' key is empty.
# https://api.instagram.com/v1/users/self/followed-by.json?access_token=ACCESS_TOKEN
# {
# "pagination": {},
# "data": [
# {
# "id": "1111111111",
# "username": "xxxx_xxxx",
# "full_name": "xxxxxxxxx",
# "profile_picture": "..."
# },
# {
# "id": "2222222222",
# "username": "yyyy_yyyy",
# "full_name": "yyyyyyyyy",
# "profile_picture": "..."
# },
# ],
# "meta": {"code": 200}
# }
You will not get pagination in sandbox mode, you will only get 20 items in response in sandbox mode, once you go live after approval, you will get pagination data to request more users.
https://www.instagram.com/developer/sandbox/
The behavior of the API when you are in sandbox mode is the same as
when your app is live, but comes with the following restrictions:
Data is restricted to sandbox users and the 20 most recent media from each sandbox user
I am trying to programmatically create and manage facebook advertising campaigns.
The following is my python code:
my_app_id = 'MyAppId'
my_app_secret = 'MyAppSecret'
my_access_token = 'MyAccessToken'
FacebookAdsApi.init(my_app_id, my_app_secret, my_access_token)
me = AdUser(fbid='MyFbId')
my_accounts = list(me.get_ad_accounts())
print(my_accounts)
Sadly, when I run this function I get an error from the following line:
my_accounts = list(me.get_ad_accounts())
The error is:
facebookads.exceptions.FacebookRequestError:
Message: Call was not successful
Method: GET
Path: https://graph.facebook.com/v2.8/643866195/adaccounts
Params: {'summary': 'true'}
Status: 400
Response:
{
"error": {
"message": "(#3) Application does not have the capability to make this API call.",
"code": 3,
"type": "OAuthException",
"fbtrace_id": "H3BFNpSClup"
}
}
I have tried messing with a few things to resolve this. One thing I thought would work was to add my account ID to the Authorized Ad Account Ids in the Facebook Develop App settings page but that didn't help.
Thanks.