How can we log Custom Activity data against leads with Marketo REST API? - marketo

We have created a Custom Activity with Marketo web portal, and we are able to create leads with REST API. So now, how can we log Custom Activity data using Marketo REST API?
Custom Activity structure is as follows:
{
"id": 100001,
"name": "TEST_ACTIVITY",
"apiName": "test_api_c",
"description": "",
"primaryAttribute": {
"name": "event_id",
"apiName": "event_id",
"dataType": "string"
},
"attributes": [
{
"name": "email",
"apiName": "email",
"dataType": "email"
},
{
"name": "event_data",
"apiName": "event_data",
"dataType": "string"
}
]
}

You can push your custom activity records to the Add Custom Activities endpoint, which is available at the POST /rest/v1/activities/external.json url.
First, worth to note, that in order to use the endpoint, the API user has to have the “Read-Write Activity” permission.
The endpoint expects a payload with a single input key, that can hold up to 300 activity records. For each activity record the leadId, activityDate, activityTypeId, primaryAttributeValue and attributes fields are required, and in case of the attributes array, the name is the normal “name” field, not the “apiName”.
In your case the payload would look something like this:
{
"input":[// Note the array of records
{
"activityDate":"2018-03-20T22:43:12+02:00",
"activityTypeId":100001,
"leadId":<LEAD_ID>,
"primaryAttributeValue":"<YOUR_EVENT_ID>",
"attributes":[
{
"name":"email",// This is the `name` field of the attribute, not the `apiName`!
"value":"<EMAIL_ADDRESS>"
},
{
"name":"event_data",// This is the `name` field of the attribute, not the `apiName`!
"value":"<EVENT_DATA>"
}
]
},
//{
// …other activity records…
//}
]
}

Related

Creatives LinkedIn API - Projection parameters not supported with new versioned API

`Hi All,
After LinkedIn API versioning, it seems that below projection parameter is not supported with creatives API call now :
com.linkedin.ads.SponsoredVideoCreativeVariables
com.linkedin.ads.SponsoredUpdateCarouselCreativeVariables
com.linkedin.ads.SpotlightCreativeVariablesV2
com.linkedin.ads.SponsoredUpdateCreativeVariables
com.linkedin.ads.JobsCreativeVariablesV2
com.linkedin.ads.SponsoredInMailCreativeVariables
Due to this, we are not able to fetch response similar to Old API call with new API now. This seems to be big impact to us.
For example , We are not receiving any of fields like 'showMemberProfilePhoto', 'forumName' for SpotlightCreativeVariablesV2 with new API which we used to get previously like mentioned below.
We have 2 headers in request as mentioned in LinkedIn API migration document.
X-Restli-Protocol-Version : 2.0.0
LinkedIn-Version : 202210
Old API call : https://api.linkedin.com/v2/adCreativesV2?ids=List({$creative_id})&projection=(results(*(variables(*,data(*,com.linkedin.ads.SpotlightCreativeVariablesV2(*,share~(*)))))))
Old API Response :
{
"results": {
"46524875": {
"variables": {
"clickUri": "$clickUri",
"data": {
"com.linkedin.ads.SpotlightCreativeVariablesV2": {
"showMemberProfilePhoto": true,
"forumName": "$forumName",
"description": "$description",
"logo": "$logo",
"headline": "$headline",
"callToAction": "$callToAction"
}
}
}
}
}
}
New API Call : https://api.linkedin.com/rest/creatives?ids=List(urn%3Ali%3AsponsoredCreative%3A{$creative_id})
New API Response :
{
"results": {
"urn:li:sponsoredCreative:$creative_id": {
"servingHoldReasons": ["$servingHoldReasons"],
"lastModifiedAt": 12345678000,
"lastModifiedBy": "",
"content": {
"reference": "urn:li:ugcPost:$ugc_post"
},
"createdAt": 1234562340000,
"isTest": false,
"createdBy": "$createdBy",
"review": {
"status": "APPROVED"
},
"isServing": false,
"campaign": "urn:li:sponsoredCampaign:$campaign_id",
"id": "urn:li:sponsoredCreative:$creative_id",
"intendedStatus": "ACTIVE",
"account": "urn:li:sponsoredAccount:$account_id"
}
},
"statuses": {
"urn:li:sponsoredCreative:creative_id": 200
},
"errors": {}
}
Is there any way to get all those fields we used to get in old API call with new API as we need these fields for processing.
`

Login With PayPal scopes not working properly

I'm working on a e-Commerce platform where sellers can sell their services. The only payment gateway I'm using is PayPal, I need to get information about the seller's PayPal account like the email address or account ID to store it and then forward payments to their account when a customer buys something from them, I plan to do this with Login With Paypal.
When I click on the button to sign in and get redirected to http://sandbox.paypal.com/signin, I type my email address and password to obtain a code using openid profile email scopes, everything goes as intended, when I add the https://uri.paypal.com/services/paypalattributes value to the scopes string to get access specifically to the account verification status and PayPal account ID though, I receive an error saying the request couldn't be processed and to try again, therefore never hitting the callback URL containing the code that I need, no matter how many times I try again I get the same error.
Just in case, I'm using a Sandbox environment. This is my Next.js Login With PayPal button code.
<Script src="https://www.paypalobjects.com/js/external/api.js"
onReady={() => {
paypal.use( ['login'], function (login) {
login.render ({
"appid":"...",
"authend":"sandbox",
"scopes":"openid profile email
https://uri.paypal.com/services/paypalattributes",
"containerid":"lippButton",
"responseType":"code",
"locale":"en-us",
"buttonType":"LWP",
"buttonShape":"pill",
"buttonSize":"lg",
"fullPage":"true",
"returnurl":"http://127.0.0.1:3000/api/paypal/callback"
})
})
}}/>
I've also checked Account verification status and PayPal account ID (payer ID) scopes in my PayPal account settings.
DevTooling the request, this is what I receive:
"errors": [
{
"message": "Invalid request during get consent content",
"locations": [
{
"line": 3,
"column": 5
}
],
"path": [
"connect",
"getConsent"
],
"extensions": {
"name": "INVALID_REQUEST",
"details": []
}
}
],
"data": {
"connect": {
"getConsent": null,
"__typename": "ConnectQuery"
}
},
"extensions": {
"tracing": {
"version": 1,
"startTime": "2022-10-07T01:54:28.831Z",
"endTime": "2022-10-07T01:54:29.053Z",
"duration": 221889707,
"execution": {
"resolvers": [
{
"path": [
"connect"
],
"parentType": "Query",
"fieldName": "connect",
"returnType": "ConnectQuery",
"startOffset": 1755903,
"duration": 28116203
},
{
"path": [
"connect",
"getConsent"
],
"parentType": "ConnectQuery",
"fieldName": "getConsent",
"returnType": "ConsentEvaluationResponse",
"startOffset": 30085850,
"duration": 188656843
}
]
}
},
"correlationId": "..."
}
}
If an account or app in the PayPal Sandbox environment appears to be behaving in a way you can't find an explanation for, the simplest resolution is often to simply create a new sandbox account/app and verify whether the problem occurs there as well. If it doesn't, use the new one -- if it does, you have have ruled out the account/app itself as an issue and can focus on configuration/integration issues or a real potential problem to report.

Is there any way to make WooCommerce REST API be friendly to customers?

I'm building an e-shop on WordPress + WooCommerce and Android app that retrieving data from WooCommerce REST API. I'm using WooCommerce's REST API with JWT to get information about products, categories, etc. also make orders, adding to cart, etc.
It's good, if you have admin's OAuth 1.0a credentials, but, I'm using customer's JWT. I made WordPress accept this auth method (by my plugin).
If I make request to http://SERVER/wp-json/wc/v3/products/categories, I will get this error:
{
"code": "woocommerce_rest_cannot_view",
"message": "Вы не можете просматривать список ресурсов.",
"data": {
"status": 403
}
}
I'm passing Authentification: Bearer "JWT" and WordPress accept it, but WooCommerce don't give me any info.
How I made WordPress accept my JWT:
function test_rest_user($result, $th, $request){
$secret_key = defined('JWT_AUTH_SECRET_KEY') ? JWT_AUTH_SECRET_KEY : false;
$auth = $request->get_header_as_array("Authorization");
if ($auth){
$token = explode(" ", $auth[0])[1];
$user = api::exchange_token_to_wp_user($token, $secret_key);
if ($user){
set_current_user($user->data->ID);
}
}
}
add_filter("rest_pre_dispatch", "test_rest_user", 10, 3);
The main topic of this question is that WooCommerce not accepting JWT. This is response from WordPress REST API with customers's JWT (http://SERVER/wp-json/wp/v2/users/me):
{
"id": 7,
"name": "test",
"url": "",
"description": "",
"link": "http://SERVER/author/test/",
"slug": "test",
"avatar_urls": {},
"meta": [],
"_links": {
"self": [
{
"href": "http://SERVER/wp-json/wp/v2/users/7"
}
],
"collection": [
{
"href": "http://SERVER/wp-json/wp/v2/users"
}
]
}
}
So, I'd temporal solution. I made function, that hooks WooCommerce REST API permissions, you can Google how to do that. It hooks from woocommerce_rest_check_permissions filter. Just check is user logged in and provide access to methods. It's so easy!

Google Analytics Reporting API - Get Activity with User ID

I can't get User Activity from the Google Analytics Reporting API (v4) using a User ID.
Client ID (in a different, non-User ID view) works, however.
Am I missing something?
--
For Client ID
I go here in my Google Analytics web interface:
https://analytics.google.com/analytics/web/#/report/visitors-user-activity/a45743608w76484324p79062844/_u.date00=20190327&_u.date01=20190402&_r.userId=1142688158.1525244974
I get user activity details as expected:
--
I call the following:
POST https://analyticsreporting.googleapis.com/v4/userActivity:search?key={YOUR_API_KEY}
{
"viewId": "79062844",
"dateRange": {
"startDate": "2019-03-27",
"endDate": "2019-04-02"
},
"user": {
"type": "CLIENT_ID",
"userId": "1142688158.1525244974"
}
}
I get the expected response:
{
"sessions": [
…
],
"totalRows": 14,
"sampleRate": 1
}
--
For User ID
I go here in my Google Analytics web interface:
https://analytics.google.com/analytics/web/#/report/visitors-user-activity/a45743608w76484324p185098721/_u.date00=20190327&_u.date01=20190402&_r.userId=Not%20Logged%20In-
I get user activity details as expected:
--
I call the following:
POST https://analyticsreporting.googleapis.com/v4/userActivity:search?key={YOUR_API_KEY}
{
"viewId": "185098721",
"dateRange": {
"startDate": "2019-03-27",
"endDate": "2019-04-02"
},
"user": {
"type": "USER_ID",
"userId": "Not Logged In-"
}
}
I get an error instead:
{
"error": {
"code": 400,
"message": "USER_ID: Not Logged In- not found.",
"status": "INVALID_ARGUMENT"
}
}
--
I have tried different IDs, different dates, changing the type to CLIENT_ID, URL encoding the User ID, and User IDs with no spaces - no joy.
It seems this is indeed a bug which several others are also experiencing.
This bug can be +1'd and followed here:
https://issuetracker.google.com/issues/130161158
Edit: This has now been fixed.
From your URL, you are looking for an ID called Not%20Logged%20In- which is not a valid id. Its probably changing the id when you copy paste the URL.

AWS AppSync GraphQL query a record by a field value

I have an user table, which consists of email, phone etc., and I would like to query a record based on its email or phone value (instead of #Id). Having not-adequate knowledge to do this - I wrote a schema like this:
type Query {
...
getUser(id: ID!): User
getUserByEmail(input: GetUserByEmailInput!): User
...
}
input GetUserByEmailInput {
email: String!
}
In resolver against getUserByEmail(..), I tried to experiment but nothing worked so far, so its remain to default state:
So when I ran a query like this to the Queries console:
query GetUserByEmail {
getUserByEmail(input: {email: "email#email.com"}) {
id
name
email
image
}
}
this returns an error like this:
{
"data": {
"getUserByEmail": null
},
"errors": [
{
"path": [
"getUserByEmail"
],
"data": null,
"errorType": "DynamoDB:AmazonDynamoDBException",
"errorInfo": null,
"locations": [
{
"line": 41,
"column": 5,
"sourceName": null
}
],
"message": "The provided key element does not match the schema (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException; Request ID: xxx)"
}
]
}
How can I query a record by non-Id field value?
If you use the Create Resources flow in the console, it will create a listUsers query that looks like the following for example. Note that the DynamoDb operation will be a Scan that has a DynamoDb filter expression where you can use any field to query DynamoDb. See below for the mapping template.
{
"version": "2017-02-28",
"operation": "Scan",
"filter": #if($context.args.filter) $util.transform.toDynamoDBFilterExpression($ctx.args.filter) #else null #end,
"limit": $util.defaultIfNull($ctx.args.limit, 20),
"nextToken": $util.toJson($util.defaultIfNullOrEmpty($ctx.args.nextToken, null)),
}
You can find more details about Scans and filter expressions in the AWS AppSync documentation:
https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-dynamodb-resolvers.html

Resources