deleting a comment oninstagram ad post - facebook-graph-api

Am trying to use this call to delete comment on an #Instagram ad post
curl -X DELETE -G \
-d "access_token=<ACCESS_TOKEN>"\
-d "ad_id=<AD_ID>"\
"https://graph.facebook.com/<API_VERSION>/<INSTAGRAM_COMMENT_ID>"
however I get the following message
{"error":{"message":"Unsupported delete request. Object with ID does not exist, cannot be loaded due to missing permissions, or does not support this operation.
Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api","type":"GraphMethodException","code":100,"fbtrace_id":"At\/K4NqgQ+9"}}
I am sure that the ad_id is valid and the permission are not missing.
is there a better way to do, any ideas?

Per https://developers.facebook.com/docs/marketing-api/guides/instagramads/post_moderation/v2.6, you need the comment ID as a URL parameter.
curl -X DELETE -G \
-d "access_token=<ACCESS_TOKEN>"\
-d "ad_id=<AD_ID>"\
"https://graph.facebook.com/<API_VERSION>/<INSTAGRAM_COMMENT_ID>"
https://graph.facebook.com// as the Graph API URL just won't work.

This has been confirmed as a bug in marketing api
https://developers.facebook.com/bugs/261618244219382/

Related

GCP - get url dynamically of cloud run instances

I have some cloud run that make http requests between them, the url is hardcoded in the code, is there a way to resolve the url by the cloud run name or another attribute?
Another possible solution could be using Method: namespaces.services.get.
If the service name is known to you, you can make a GET HTTP request in API calls to https://{endpoint}/apis/serving.knative.dev/v1/{name} where endpoint is one of the supported endpoints and name is the name of the Cloud Run service to retrieve. For Cloud Run (fully managed), replace {namespace_id} with the project ID or number. It takes the form namespaces/{namespace}/services/{service}.
Authorization requires the following IAM permission on the specified resource name : run.services.get
For example :
curl -X GET -H "Authorization: Bearer $(gcloud auth print-access-token)" https://us-central1-run.googleapis.com/apis/serving.knative.dev/v1/namespaces/your-project/services/your-service| grep url
Output :
"url" :"https://cloud-run-xxxxxxxxxx-uc.a.run.app"
There is a gcloud command to do so. You could for instance get the url during your build and save it into an environment variable. The following command will get the complete url:
gcloud run services describe YOUR_CLOUDRUN_NAME --region=INSTANCE_REGION --platform=managed --format=yaml | grep -m 1 url | awk '{print $NF}'
There is no easy way for now (but Cloud Next 21 is coming, maybe great announcement on that; it's a feature requested by many Alpha tester like me).
However, you can implement a bunch of API calls to achieve that. I wrote an article where I use that to get the current Cloud Run service URL. But it could be another service.
It's in Golang. Have a look on it, and let me know if you have issues to translate the calls in your preferred language.
You can:
gcloud run services ${NAME} \
--platform=managed \
--region=${REGION} \
--project=${PROJECT} \
--format="value(status.address.url)")

How to authorize when sending email with Mailgun?

I would like to send email with Mailgun via Postman. I write my Private API key in all different way in the Authorization section in Postman. But it always refuse me, got a HTTP 401.
What is wrong?
I tried send via CURL as tutorial suggest, but is fails also:
https://documentation.mailgun.com/en/latest/quickstart-sending.html#send-via-api
kukodajanos#Kukoda-MacBook-Pro-2 ~ % curl -s --user 'api:b3c5...' \
https://api.mailgun.net/v3/mg.tiket.hu/messages \
-F from='janosontech#gmail.com' \
-F to=kukodajanos#icloud.com \
-F subject='Hello' \
-F text='Testing some Mailgun awesomeness!'
Forbidden%
Basic authentication (as in your first screenshot) should work. (Also make sure, you don't have any spaces, newlines or other wrong characters included in your token)
Are you using your primary API key or a sending key specifically for that domain? If the first, try creating a sending key for you domain. If the latter, try recreating the key.

How to delete added attestation in google cloud platform's kubernetes engine image authorization process

I have added an attestation on google cloud platform to use for image signing and attestation by the attestor and want to remove the added attestation but I can't seem to find any documentation on how this is done or even if this is how is should be done.
I have seen the one for removal of the attestor but none on removing of deleting the attestation. I had added it using the following command:
Official documentation version:
gcloud container binauthz attestations create \
--project=$PROJECT_ID \
--artifact-url="${CONTAINER_PATH}#${DIGEST}" \
--attestor=${ATTESTOR} \
--signature-file=./signature.pgp \
--public-key-id="$KEY_FINGERPRINT"
Online tutorial version:
gcloud beta container binauthz attestations create \
--artifact-url="CONTAINER_PATH#DIGEST" \
--attestor=ATTESTOT_ID \
--attestor-project=PROJECT_ID \
--signature-file=./signature.pgp \
--pgp-key-fingerprint="KEY_FINGERPRINT"
but from a more recent documentation the --attestor should include the following --attestor="projects/${ATTESTOR_PROJECT_ID}/attestors/${ATTESTOR}" and unfortunately the tutorial I am following didn't use it this way and only added the attestor_id or name. So I want to remove this version and add new one but I am getting a conflict error
Resource in project [xxxx] is the subject of a conflict: occurrence ID "f5981e62-7b42-4f57-8486-b0d9518509fa" already exists in project
So how is it to be removed.
Update: documentation used to compare to online course: https://cloud.google.com/binary-authorization/docs/making-attestations
Looks like somekind of underlying resources(the error messages indicates that) are still need to be deleted.
Found some documentation on binary authorization where they have explained complete tear down and clean-up. It looks like apart from the attestor, we need to delete some other connected resources as well.
According to the official Google Cloud Documentation on Creating attestations and project occurrences DELETE REST API method documentation, I derived the curl command to delete a specific attestations:
curl "https://containeranalysis.googleapis.com/v1beta1/projects/${ATTESTATION_PROJECT_ID}/occurrences/${OCCURRENCES_GUID}" \
--request DELETE --header "Content-Type: application/json" \
--header "Authorization: Bearer $(gcloud auth print-access-token)"
Assuming the executing user has containeranalysis.occurrences.delete permission as included in roles/containeranalysis.occurrences.editor, the response would be 200 with an empty json. I am not sure if the following header is required but at the time of my testing it wasn't.
-H "X-Goog-User-Project: ${ATTESTATION_PROJECT_ID}"
I have provided feedback to Google Cloud documentation to include my curl command above at the official Google Cloud Documentation on Creating attestations

How to update a ticket state via REST

OTRS 7.0.x provides a REST API. I've found various useful endpoints, but I can't find one where you could update the state of a ticket with a given TicketID. Is there a solution for this problem?
[OTRS 8.0.x isn't out yet, how do you have access to it? resolved by edit]
You can take a look at the TicketUpdate operation. In the file is a description on what you must and what you can provide. With this you can update the ticket state via REST.
Here's an example call for the rest interface to change the state of the ticket.
curl "http://localhost/otrs/nph-genericinterface.pl/Webservice/WebServiceName/RoutingOfTheOperation?UserLogin=admin&Password=1234&TicketID=1" -H "Content-Type: application/json" -d '{"Ticket":{"State":"closed"}}' -X POST

Connect to elasticsearch in AWS using key credentials

I'm trying to post a request using curl to my es cluster in AWS using my accessKey and secretKey. I have successfully done this through postman (details here) where you can specify AWS credentials but I would like to make this work with curl. Postman can auto-generate your curl request for you but all I get are errors.
This is the generated curl request along with the response
curl -X GET \
https://search-00000000000001.eu-west-1.es.amazonaws.com/_cat/indices \
-H 'Authorization: AWS4-HMAC-SHA256 Credential=11111111111111111111/20181119/eu-west-1/es/aws4_request, SignedHeaders=cache-control;content-type;host;postman-token;x-amz-date, Signature=11111111116401882398f46011f14fdb9d55e012a4fb912706d67c1111111111' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Host: search-00000000000001.eu-west-1.es.amazonaws.com' \
-H 'Postman-Token: 00000000-0000-4001-8006-9291e208a000' \
-H 'X-Amz-Date: 20181119T220000Z' \
-H 'cache-control: no-cache'
{"message":"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details."}%
IDs have been changed to protect the innocent.
I have checked all my keys and region, and like i said this works through postman. Is it possible to access this AWS service using my keys through curl?
This is quite a long rabbit hole. Thanks to Adam for the comment that sent me in the correct direction. The link https://docs.aws.amazon.com/apigateway/api-reference/signing-requests/ really helps you understand what you need to do.
I've since found a script that follows the signing requests method outlined above. It runs in bash and whilst it is not written for use with elasticsearch requests it can be used for them.
https://github.com/riboseinc/aws-authenticating-secgroup-scripts many thanks to https://www.ribose.com for putting this on github.
If your host contains ':443' remove it and try again.
This worked for me.
"My initial problem: If I access it with Postman using the same url, I get the same error, but removing the ‘:443/’, it works fine, so it’s nothing wrong with the key and secret I’m using."