Marketo REST API - increment field - marketo

If i have a custom object with an integer field, is there a way to send a request to increment this field by 1?
Or would i have to get that field's value, increment it and send it back?

Unfortunately, you cannot increment such a value with a single API call, so you either have to
keep track of your records outside of Marketo too, and update Marketo with the current value;
or you have to use two API calls: one to fetch the record, and a second one to send back the updated value.
Note:
While it is possible to increment/decrement the Score field type (which is also an integer field) with integer values, it is only possible to do so through the Change Score flow step within Marketo. Besides that, the Score type is not available for custom objects.
To be sure, I just have tried to increment an integer value via the API by setting “+1” as a sent value, but it was recorded as plain “1”, so the original record has been overwritten.

Related

With all Firebase products, Is it possible to return a positive integer with out repeat

Same as SQL, you can add a new row with the primary key being auto incremental.
We need a counter where we can get unique values ​​even if we call them at the same time. (the result should be n and n+1)
Is it possible for all firebase products to create a counter that returns you a value that is never the same?
Eg.
It's possible to tell that user from firebase authentication is the first, second or third from a register (the sequence should never change) if it's so it would be great
A counter that gives you a number that never is the same even I and others request at the same time.
Main purpose
I want a 1-1 map, a positive integer (UInt32) to firebase account UID
eg. 1: aksd12391, 2: da1293nvs1dks, 4: 1is91jesoc
Using Transaction's Firestore (Concurrency)
It still returns the same not unique
Is it possible to create a counter that
returns you a value that is never the same?
Yes, you can use a numeric field in a Firestore document that you (transactionally) increment as explained here in the doc.
It's possible to tell that user from Firebase authentication is the
first, second or third from a register (the sequence should never
change)
Yes, you can assign a unique value (obtained as explained above) to a user, by, for example, saving a user profile in Firestore and assigning this value as a "functional" id.

How to get the custom updates in telegram

I try to use https://api.telegram.org/bot<token>/getupdates to get updates from telegram with robot, and how can I get custom updates?
Such as, I want to get updates from one telegram group, and in specified time?
Currently there's no way to do that.
You have to process all the updates from the API server in Telegram-specified format. The only thing you can provide as a query filter is an offset parameter.
UPD
If the problem is that you always receive the same set of updates, the reason is that you're specifying incorrect offset parameter for getUpdates method.
From the API docs page:
In order to avoid getting duplicate updates, recalculate offset after each server response
So offset must be different every time you call getUpdates.
How to calculate offset for every call:
getUpdatesrequest returns an array of Update objects.
Every Update object has a update_id property. Iterate over this array, find and store the maximum update_id in a variable (max_upd_id for example).
Use max_upd_id + 1 as a new offset in the next getUpdates call.
For the very first call of getUpdates use offset=0.

Marketo REST API - what is "dedupeFields" for custom objects?

When it comes to creating/updating custom objects, can I use both dedupeFields or lookupField when pushing the data to Marketo?
What is the difference between the two?
I'm not sure what do you mean under lookupField, as there is no such input field described in the API documentation of the Sync Custom Objects endpoint. (That is the endpoint to create or update custom objects.)
In the other hand, you do not need such a standalone lookup field, as with the input array you provide the objects you want to create or update, with all their important values. Have a look at the sample payload in the docs.
When input is used together with the optional dedupeBy and action fields, you have full control over which object you want to create or update.
Also, the endpoint expects the name of the dedupe field under dedupeBy key, as opposed to dedupeFields. So the name is singular; you can provide a single field name use, and it does what you can expect: if the value in the field for a given record is not unique, an error will be returned for the individual record.

Marketo Leads - How to find the updated values of progressionStatus field

I need to get the Marketo Leads who have changes on "progressionStatus" field (inside membership) with the API.
I can get all the leads related to a Program (with Get Leads by ProgramID API) without issues, but my need is to get those Leads with changes on "progressionStatus" column.
I was thinking to use the CreatedAt / UpdatedAt fields of the Program, so then, get all the leads related to those programs. But I didn't get the accurate results that I want.
Also, I tried to use the GET Lead changes API and use "fields" parameter to "progressionstatus" but that field don't exist.
It is possible to resolve this?
Thanks in advance.
You can get the list of Leads with progression status change by querying against the Get Lead Activities endpoint.
The Get Lead Changes endpoint could sound as a good candidate, but that endpoint only returns changes on the lead fields. Progression status change is not stored on the lead directly, so at the end that won't work. On the other hand the Get Leads by ProgramId endpoint returns –amongst others– the actual value of progressionStatus (program status of the lead in the parent program) but not the “change” itself, so you cannot process the resultset based on that.
The good news is that the progression status change is an activity type and luckily we have the above mentioned Get Lead Activities endpoint (which is also mentioned as the Query in the API docs) available to query just that. This endpoint also allows for filtering by activityTypeIds to narrow down the resultset to a single activity type.
Basically you have to call the GET /rest/v1/activities.json enpoint and pass the values of activityTypeIds and nextPageToken as query parameters (next to the access token obviously). So, first you need to get the internal Id of the activity type called “Change Status in Progression”. You can do that by querying the GET /rest/v1/activities/types.json endpoint and look for a record with that name. (I don't know if this Id changes from instance to instance, but in ours it is the #104). Also, to obtain a nextPageToken you have to make a call to GET /rest/v1/activities/pagingtoken.json as well, where you have to specify the earliest datetime to retrieve activities from. See more about Paging Tokens.
Once you have all of these bits at hand, you can make your request like that:
GET https://<INSTANCE_ID>.mktorest.com/rest/v1/activities.json?activityTypeIds=<TYPE_ID>&nextPageToken=<NEXTPAGE_TOKEN>&access_token=<ACCESS_TOKEN>
The result it gives is an array with items like below, which is easy to process further.
{
"id":712630,
"marketoGUID":"712630",
"leadId":824864,
"activityDate":"2017-12-01T08:51:13Z",
"activityTypeId":104,
"primaryAttributeValueId":1104,
"primaryAttributeValue":"PROGRAM_NAME",
"attributes":[
{"name":"Acquired By","value":true},
{"name":"New Status ID","value":33},
{"name":"Old Status ID","value":32},
{"name":"Reason","value":"Filled out form"},
{"name":"Success","value":false},
{"name":"New Status","value":"Filled-out Form"},
{"name":"Old Status","value":"Not in Program"}
]
}
Knowing the leadIds in question, you can make yet another request to fetch the actual lead records.

Voting on items - how to design database/aws-lambda to minimize AWS costs

I'm working on a website that mostly displays items created by registered users. So I'd say 95% of API calls are to read a single item and 5% are to store a single item. System is designed with AWS API Gateway that calls AWS Lambda function which manipulates data in DynamoDB.
My next step is to implement voting system (upvote/downvote) with basic fetaures:
Each registered user can vote only once per item, and later is only allowed to change that vote.
number of votes needs to be displayed to all users next to every item.
items have only single-item views, and are (almost) never displayed in a list view.
only list view I need is "top 100 items by votes" but it is ok to calculate this once per day and serve cached version
My goal is to design a database/lambda to minimize costs of AWS. It's easy to make the logic work but I'm not sure if my solution is the optimal one:
My items table currently has hashkey slug and sortkey version
I created items-votes table with hashkey slug and sortkey user and also voted field (containing -1 or 1)
I added field votes to items table
API call to upvote/downvote inserts to item-votes table but before checks constraints that user has not already voted that way. Then in second query updates items table with updated votes count. (so 1 API call and 2 db queries)
old API call to show an item stays the same but grabs new votes count too (1 API call and 1 db query)
I was wondering if this can be done even better with avoiding new items-votes table and storing user votes inside items table? It looks like it is possible to save one query that way, and half the lambda execution time but I'm worried it might make that table too big/complex. Each user field is a 10 chars user ID so if item gets thousands of votes I'm not sure how Lambda/DynamoDB will behave compared to original solution.
I don't expect thousands of votes any time soon, but it is not impossible to happen to a few items and I'd like to avoid situation where I need to migrate to different solution in the near future.
I would suggest to have a SET DynamoDB (i.e. SS) attribute to maintain the list of users who voted against the item. Something like below:-
upvotes : ['user1', 'user2']
downvotes : ['user1', 'user2']
When you update the votes using UpdateExpression, you can use ADD operator which adds users to SET only if it doesn't exists.
ADD - Adds the specified value to the item, if the attribute does not
already exist. If the attribute does exist, then the behavior of ADD
depends on the data type of the attribute:
If the existing data type is a set and if Value is also a set, then
Value is added to the existing set. For example, if the attribute
value is the set [1,2], and the ADD action specified [3], then the
final attribute value is [1,2,3]. An error occurs if an ADD action is
specified for a set attribute and the attribute type specified does
not match the existing set type. Both sets must have the same
primitive data type. For example, if the existing data type is a set
of strings, the Value must also be a set of strings.
This way you don't need to check whether the user already upvote or downvote for the item or not.
Only thing you may need to ensure is that the same user shouldn't be present on upvote and downvote set. Probably, you can use REMOVE or ConditionExpression to achieve this.

Resources