I am trying to post (share) to LinkedIn using R and the REST api. I followed the code example here: https://github.com/hadley/httr/blob/master/demo/oauth2-linkedin.r
It does a GET call which is working for me, but I haven't managed to get the POST to work right. The error I receive is:
Date: 2015-09-17 10:00
Status: 403
Content-Type: application/json;charset=UTF-8
Size: 144 B
{
"errorCode": 0,
"message": "Access to posting shares denied",
"requestId": "XXXXXXXXXX",
"status": 403,
"timestamp": 1442509229748
Below is the code I am trying to use:
POST("https://api.linkedin.com/v1/people/~/shares?format=json",
body = list(
content = list(title="Title",
description ="Description"),
comment = "Comment",
visibility = list(code="anyone")
),
config=list(token = token)
)
#submitted-url=url,
#submitted-image-url=imageurl
The documentation is here: https://developer.linkedin.com/docs/share-on-linkedin
I have w_share enabled in the application, so I am not sure what the problem is. Do I need the "submitted-url" and "submitted-image-url"?
I'd appreciate a working POST code example.
Thanks.
Related
I have been trying to authenticate from the parser API without success.
I have set up the google service account and created two keys.I Have set up the owner role and downloaded the credential json file.
googleAuthR::gar_auth_service("D:/898 sample/document ai/form-898-scan-bd4b8b48b570.json")
library(daiR)
response1 <- dai_sync("D:/test file.pdf"
,
proj_id = get_project_id(path = "D:/crudentialabc123.json"),
proc_id = "e4xxxxxx",
loc = "us",
token = dai_token(
path = Sys.getenv("GSC_AUTH_FILE")
# scopes = "https://googleapis.com/auth/cloud-platform"
)
)
I keep getting the 403 permission denied error.
File submitted at 2022-04-10 05:17:57. HTTP status: 403 - unsuccessful.
Error: "Permission 'documentai.processors.processOnline' denied on resource '//documentai.googleapis.com/projects/projectname/locations/us/processors/e4xxxxxxx' (or it may not exist)."
Response [https://us-documentai.googleapis.com/v1/projects/projectname/locations/us/processors/e46888f802fea83d:process]
Date: 2022-04-10 05:17
Status: 403
Content-Type: application/json; charset=UTF-8
Size: 649 B
{
"error": {
"code": 403,
"message": "Permission 'documentai.processors.processOnline' denied on resource '//documentai.googleapis.com/projects/form-898-scan/locations/us/processors/e46...
"status": "PERMISSION_DENIED",
"details": [
{
"#type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "IAM_PERMISSION_DENIED",
"domain": "documentai.googleapis.com",
...
Any help would be appreciated!
I would recommend reviewing this blog post about Google authentication using R.
https://cran.r-project.org/web/packages/googleAuthR/vignettes/google-authentication-types.html
Currently, Google Cloud doesn't have any client libraries for R, but the 3rd party packages listed should be able to provide a starting point.
When I try to get all the comments below a facebook page post using the graph api explorer via
GET
https://graph.facebook.com/12.0/{post-id}?fields=comments
the answer looks like:
{
"error": {
"message": "(#200) Missing Permissions",
"type": "OAuthException",
"code": 200,
"fbtrace_id": "AqyOUwmTl...3n5y-Br"
}
}
Why?
In case I just request the post like
GET
https://graph.facebook.com/12.0/{post-id}
I got back a valid answer:
{
"created_time": "2021-12-21T10:05:40+0000",
"message": "This is a test post.",
"id": "x0xxxxxxxxxx95_1xxxxxxxxx74"
}
This is kinda strange because I request these datas with an admin user of the facebook page and set the following permissions for the access token:
read_insights
pages_show_list
instagram_basic
publish_to_groups
pages_read_engagement
pages_read_user_content
pages_manage_posts
public_profile
Appreciate any help, thank you.
Instead of use "User token" you have to use "Page token"
I am trying to learn how to update values on Wikidata using the API. Login and csrf cookies work ok, but when I try to update a value I get an invalid-snak error.
The request body looks like this:
POST /w/api.php HTTP/1.1
Accept-Encoding: gzip
Content-Length: 178
User-Agent: Mojolicious (Perl)
Host: test.wikidata.org
Content-Type: application/x-www-form-urlencoded
Cookie: [omitted]
action=wbcreateclaim&bot=1&entity=Q3345&format=json&property=P9876&snaktype=value&token=[omitted]&value=%7B%22entity-type%22%3A%22Q1917%22%7D
and the response is:
{
"error": {
"code": "invalid-snak",
"info": "Invalid snak data.",
"messages": [
{
"name": "wikibase-api-invalid-snak",
"parameters": [],
"html": {
"*": "Invalid snak data."
}
}
],
"*": "See https://test.wikidata.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes."
},
"servedby": "mw1386"
}
I've tried various ways to succeed with an update by changing the value - no results. The only update I succeeded with is one with snaktype=novalue - which would confirm that the issue is with the snak vaue alone.
So the question is, what's the right way to make an update to a snakvalue?
The problem is that you are stating value={"entity-type":"Q1917"}, but Q1917 is not an entity-type!
You should instead state value={"entity-type":"item","numeric-id":1917}.
For deepen the topic, see the Wikidata API's documentation.
Request to API-Endpoint:
POST https://advertising-api-eu.amazon.com/v2/asins/report
Official documentation:
https://advertising.amazon.com/API/docs/en-us/reference/sponsored-products/2/reports
Headers:
Authorization: Bearer Atza|xxxxxxxxxxxxxxxxxxxxx
Content-Type: application/json
Amazon-Advertising-API-ClientId: xxxxxxxxxxxxxxxxxxxxxxxxxx
Amazon-Advertising-API-SCOPE: xxxxxxxxxxxxxxxxxxxxxxx
Request:
{
"segment": "query",
"reportDate":"20200201",
"metrics": "campaignName,campaignId,adGroupName,adGroupId,keywordId,keywordText,asin,otherAsin,currency,matchType,attributedUnitsOrdered30d,attributedUnitsOrdered30dOtherSKU,attributedSales30dOtherSKU"
}
Response:
{
"code": "400",
"details": "Missing campaign type",
"requestId": "7Q8PMWM2618KAS0VEG87"
}
Question:
I think the error message is misleading (because i checked the documentation twice and because of my former experiences with the API).
But what is the real error? How can i get a ASINs report?
I asked Amazon Support and they replied:
"Asin report would need campaignType in the payload to succeed the operation. We have a documentation update pending on this. Please be noted that query segmentation is only allowed for keyword, target and productAds report. An example payload:-
GET https://advertising-api.amazon.com/v2/asins/report"
{
"reportDate":"20200201",
"campaignType": "sponsoredProducts",
"metrics":"campaignName,
campaignId,
adGroupName,
adGroupId,
keywordId,
keywordText,
asin,
otherAsin,
currency,
matchType,
attributedUnitsOrdered30d,
attributedUnitsOrdered30dOtherSKU,
attributedSales30dOtherSKU"
}
I have a linkedin company page.I am trying to post a comment on an already existed post of that page via Linkedin Rest API.
Below are the request details :
HTTP METHOD : POST
URL : https://api.linkedin.com/v2/socialActions/urn:li:activity:{activity-id}/comments
HEADERS : Authorization, Content-Type
BODY :
{"actor": "urn:li:organizationBrand:<org id>",
"message": {
"attributes": [],
"text": "This is a comment"
}}
The above request is throwing me the below error :
{"message": "com.linkedin.restli.client.RestLiResponseException: Response status 500, serviceErrorMessage: Error creating comment",
"status": 500}
The same request works for me for another linkedin company page. Can you please help me on finding what the issue is?