Add a tag to an existing contact using the Mautic API - mautic

I've been driving myself crazy for days trying to figure it out.
When I search "tags" in the docs, the only results seem to relate to creating and editing the tag records themselves rather than any association to a contact's record.
I see this test class linked from this issue but don't understand since there isn't actual documentation or a simple example of how to use the API to add a tag to a contact.
I'd appreciate any help. Thanks.
'tags' => ['tag1', 'tag2']
P.S. That test class code seems to be for creating a new contact with certain tags, when instead what I want to do is associate an existing tag with an existing contact.

It's the same payload for create and update as well.
Endpoint: PATCH api/contacts/ID/edit
With data: tags[0]=tagA
which will URL decode to: tags%5B0%5D=tagA
Or you can use JSON format for the data payload if you specify it in the header ('Content-Type: application/json'):
{
"tags": ["tagA"]
}
The request is containing the tag like this:
{
"contact": {
...
"tags": [
{
"id": 32,
"tag": "tagA"
}
],
...
}

Related

How to add taxonomies in 11ty?

I'd like to use a json-file that looks somewhat like this
[{
"id": "foo",
"url": "video",
"topic": "Fancy foos"},
{
"id": "bars",
"url": "video",
"topic": "Naughty bars"
}]
as a source for several overview pages that group the entries by topic (I guess it's called taxonomy). What would be a good solution for this? Parse the json, group it with js and create a custom collection for each topic? If so, where would this belong, to a file in the _data folder?
Thx in advance!
I'm not 100% sure I get what you intend, but let me try to help. First, yes, store the file in your _data folder. Let's assume you call it taxonomies.json. This means your code has access to the array as taxonomies.
Next, if you want to build pages based on this data, look at the docs for Create Pages from Data, which describe how to dynamically generate pages based on your data. You could have one per taxonomy. For ex:
---
pagination:
data: taxonomies
size: 1
alias: tax
permalink: "topic/{{ tax.id | slug }}/"
---
content here
Your content needs to be driven by the current taxonomy. I assume you will have a kind of content, like posts, that include a taxonomy? If so, you can create a short code or filter that scans all posts and returns the one with a particular taxonomy in the front data. For example, here's how I get posts that match a category:
{% assign posts = collections.posts | getByCategory: cat %}
And getByCategory is defined in .eleventy.js. The particulars of this part are really dependent on what content you are trying to show.

Change Eve Python DOMAIN collection schema dynamically during runtime

I am using the Eve Python API Framework for MongoDB. I am writing a feature that allows my users to edit metadata sections for the documents that they are writing.
Example JSON:
{
"metadata": {
"document_type": ["story"],
"keywords": ["fantasy", "thriller"]
}
}
We have a CMS for the document editor that admins can use to allow them to do things like add new metadata fields for the authors (normal users) to add more information about their posts. For example, the site admin may want to add a field called "additional_authors" which is a list of strings. If they add this section to the frontend we would like some way to add it to the Eve Schema on the backend in real time without restarting the server. It is very important that it be real time and not part of a coding change in Eve or requiring Eve to restart.
Our current hard-coded metadata schema looks like this for the document collection:
{
"metadata": {
"type": "dict",
"schema": {
"document_type": {"type": "list", "required": True},
"keywords": {"type": "list", "required": True}
}
}
}
I understand that we can go with a non-strict approach when writing the "metadata" type dict so that it does not care what is inside but from my understanding this means we would not be able to use "projection" properly meaning that if I only wanted to return "metadata.additional_authors" of all documents through my API call, I would not be able to do so. Also, this would mean that we would have to deal with the required check ourselves using hooks instead of the built-in Eve schema check.
Is there anyway around this issue by essentially having a dynamic schema based on a MongoDB document that we can store the entire collection configuration dict in and retrieve it without restarting the server for it to take effect? Even if this means adding a hook to the new schema_dict collection and calling some internal Eve function I am all ears.
Thank you ahead of time for your help.

Podio API - GET form

Looking for some help from an experienced Podio API navigator!
I'm trying to build a feature into our rails app where I can pull the details of a form from Podio, so that I can then automatically generate a form in our environemnt that can post to the app.
To do that I would need to get the category and labels of the fields..
However, when you GET a form from podio, this is all it gives you for the fields:
"fields": [
{
"field_id": foo,
"settings": null
},
{
"field_id": foo,
"settings": null
}
any thoughts on how I might use this information to get the information that I need? Can I somehow use the field_id to GET the field?
You can get the app and the fields within it by using GET request to,
/app/{app_id}/field/{field_or_external_id}

Can i post a task to a specific location in a project through asana API?

I'm trying to post a task within a project under a certain section, does anyone have any suggestions as to go about doing it/ is it even possible?
Thanks
Well, you are in luck! We are right now working on improving our support for sections in the API.
To add a task to a given section, you can use the addProject method with a section parameter, which is similar to insert_before or insert_after. An example call would look like POST /tasks/1234/addProject?project=111&section=7865.
Now, that's an extra call you need to make after you create the task, which is a bummer, so we're also working on a way to specify sections when you create the task. But we're literally working on that right now. I'll edit this answer when that exists.
To POST a new task to a project in a specific section (column) hit the workspace URL
https://app.asana.com/api/1.0/workspaces/[workspace-id]/tasks
You need to declare the memberships property in your POST request, the API documentation makes this very confusing.
Here is how it should be:
"memberships": [{
"project": 12345,
"section": 12345
}]
The API documentation makes it seem like you need to also include the name that goes along with the project and section.
Here is their example from the docs which is NOT how it should be done:
[{ project: { id: 1331, name: 'Bugs' }, section: { id: 1123, name: 'P1:' } }]
I found this answer here: https://community.asana.com/t/how-create-task-with-membership-via-api/10481/2

JIRA API create issue with custom fields

i want to create an issue in JIRA by using the REST API provided by JIRA.
i am able to create a simple issue,
using this :
http://localhost:8080/rest/api/latest/issue
and data as follows:
{"fields":{"project":{"key": "TES"},"summary":"user name not showing validation message","description":"Hi validation is missing from user name","issuetype": {"name": "Bug"},"reporter":{"name":"BruceWayne"} }}
this is running fine.
now i want to add 3 custom fields while creating an issue. The custom fields are Authorname,
AuthorTag,AuthorID. how can i do this in rest api. what should i add in my data.
My sample data is as follows:-
{"fields":{"project":{"key": "TES"},"summary":"my bugs 5","description":"Hi","issuetype": {"name": "Bug"},
"customfield_10000":"roach#yahoo.com",
"customfield_10100":{"value":"abc"},
"reporter":{"name":"amit"},
"components": [{
"add" : {"name" : "abc"}
}],"priority": {
"id": "1"
}
}}
i want to use the names specified for customfields rather than customfield_XXXXX .
One way i think of is to hit the API after creating a simple issue ( using another API hit to get meta data as follows)
http://localhost:8080/rest/api/latest/issue/tes-79?expand=editmeta
and then do json parsing and again issue a put command to update the fields in same issue
but i was looking for a way to do it in single API hit (while creating an issue)
It should be just like setting any other field, but you have to use the field name "customfield_NNNNN" instead
I know that it is very late to answer this question, but then might help others if not the OP at this time of writing.
If you're in doubt about the create, then you could do something like this - Try a GET on an issue that you would rather create manually with the new parameters as well and then based on the output of the same you could then decide to update it with the new parameters with the new name or the old-fashioned customfield_xxx field.
Try a GET like this on cURL
curl -D- -u fred:fred -X GET -H "Content-Type: application/json" https://jira.fred.com/rest/api/2/issue/FRD-88651
Then you could possibly do a POST like how you've done earlier:
http://localhost:8080/rest/api/latest/issue

Resources