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

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

Related

MS Graph API ... create Planner task including details/description using one single HTTP request?

I am using the Microsoft Graph API to create Planner tasks, and I am wondering if there is a way to create a task including task details/description using a single HTTP request.
This old question from 2018 is asking about the same thing. The outcome in 2018 was that several separate requests were necessary ... first creating the task, then getting and updating its details object, which is a somewhat cumbersome process.
The original answerer has recently updated their answer to say that this behavior has changed and "you can set task details fields in the same request as creating the task". However, I'm confused as to whether this applies to the REST API itself, or to the Microsoft SDKs (which I am not currently using, as I don't need most of their functionality).
When I make a POST request to the /planner/tasks endpoint, and supply the details object in the body like such ...
{
"planId": "(... plan ID ...)",
"bucketId": "(... bucket ID ...)",
"title": "Title for new task",
"details": {
"description": "Some description for new task"
},
"assignments": {
(... assignment data ...)
}
}
... the task is created, but I don't see any description/notes. This applies both to the "v1.0" and "beta" APIs. (I tried the newer "notes" property on the beta API as well, with the same result.)
Based on the MS docs I could not find a conclusive answer either.
Should a request such as the one I listed work right now? If yes, in which API version? If no, what am I missing?
Thanks!
That request should work, but there is an issue with the returned response to the create operation not including the task details. If you read the task details after the creation (or reading task expanding the details), the description should be there.

Alchemy CMS: Create element that contains list of elements

I'd like to create an element which can contain a list of items, where each item can have more than one essences.
For example:
The user should be able to add a "page listing" as content element. For each page item he should be able to upload a small image, a short description and a link. Because the list needs to be wrapped with an UL tag, I can't simply ask him to add a lot of elements.
Other example:
The user should be able to add a "team listing" as content element. Each member having a photo, a name, a job description and an email address. Same problem here: I'd like to have the team members wrapped within an DL tag.
Is there some way of releasing elements which can contain elements?
Some kind like: (just an example, might contain bugs)
- name: my_list_element
contents:
- name: list_style
type: EssenceSelect
- name: items
type: Element ???
elements: [my_item_element]
settings:
deletable: true
available_contents:
- name: items
type: Element ???
elements: [my_item_element]
settings:
deletable: true
- name: my_item_element
contents:
- name: image
type: EssencePicture
- name: headline
type: EssenceText
...
The inner item uses the default editor for pictures or text essences.
If someone knows a way how to realize this it would be very great, because it's the last puzzle part which is missing in order to use alchemy CMS :(
Thank you in advance
You want to use the new nestable Elements feature you'll find in the current master and soon to be released 3.3 version. Unfortunately they are not well documented yet. Sorry.
But it's really simple. Instead of the available_contents (That will be deprecated in favor of nested elements anyway, you list names of nestable_elements).
A nestable element can be any element you have defined.
Unless the guides got updated, please read the documentation in the code.
You may use http://ruby-doc.org/stdlib-2.1.0/libdoc/yaml/rdoc/YAML.html and get Hash in the output and also save it in text as well
Hope to see nestable_elements feature soon, may be it will solve some really obvious tasks. For now, without the possibility to easy extend Alchemy with custom models (Post, TeamMember, Testimonial, PortfolioItem, etc) I am still the fan on RefineryCMS or pure RoR, and this is sad, because AlchemyCMS has really nice things built-in.
As I can understand, this feature will be implemented in Alchemy 4 by Nodes, even the Page model will be registered as Alchemy::Node, and developer will be able to create own Nodes which will behave like custom_post_type in WordPress.

How to add a flag to jira issue via rest api

I would like to be able to add a flag to an issue via the Jira API. I was unable to find any documentation regarding this issue. Does anyone know how this works?
I've figured out how to do this, I'm not sure on the version of the API. I made a POST request to:
yourdomain /rest/greenhopper/1.0/xboard/issue/flag/flag.json
And in the body (replace JIRA-ISSUE with your issue key):
{"issueKeys":["JIRA-ISSUE"],"flag":true}
I hope this helps.
Here is the best answer I found.
https://answers.atlassian.com/questions/38062844/answers/38062897
There is a field called Flagged. It is a checkbox type field. There is a single value by default, Impediment. The field is checked for null status. If the field is null, the issue is not flagged. If the field is not null, the issue is flagged.
You would use the REST API for this. Examples are here –
https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-create-issue.
You'll either need to know the field ID (customfield_10000) or you need to to script the discovery of the field by searching the metadata – https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-discovering-meta-data-for-creating-issues.
An example of setting a custom field while creating the issue over API –
curl -D- -u fred:fred -X POST --data {"fields":{"project":{"key": "TEST"}, "summary": "Always do right. This will gratify some people and astonish the REST.", "description": "Creating an issue while setting custom field values", "issuetype":{"name": "Bug"}, "customfield_10000": [{"value": "Impediment"}]}} -H "Content-Type: application/json" http://localhost:8090/rest/api/2/issue/
non-minified data Expand source
{
"fields": {
"project":
{
"key": "TEST"
},
"summary": "Always do right. This will gratify some people and astonish the REST.",
"description": "Creating an issue while setting custom field values",
"issuetype": {
"name": "Bug"
},
"customfield_10000": [ {"value": "Impediment" }]
}
}
As mentioned here, "Flagged" is a checkbox custom field that accepts a single value "Impediment".
You should be able to set it using the JIRA REST API just like any other custom field. Maybe the examples here will help.
You can also set custom field values using the JIRA Java API.
I'm struggling with this right now. It seems that the Flagged field is not a checkbox type field anymore, but multicheckbox. So the data format I need to send to Jira Cloud API to set the flag in my case look like this:
{update:
{customfield_10021:
[{set:
[{id:“10019”}]
}]
}
}
To remove the flag the data I sent to Jira look like this:
{update:
{customfield_10021:
[{set:
[]
}]
}
}
In the above customfield_10021 is Flagged field's key and 10019 is id that sets the flag. Both of them you need to figure out for your Jira Cloud instance for example by aquiring issue with set Flagged field and checking how it is set.
Just to make it clear, to add/remove a flag I use edit issue end point described here.
Also, to be able to add/remove flag the Flagged field has to be on the edit screen of the issue type that you want to modify and your user needs to have proper priviliges.

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

Saving Rails model as JSON

This seems like a question that would have already been asked, but I couldn't find quite what I was looking for, so I'll just go ahead and ask.
I'm trying to use angular.js to make an instant search function on my site. I want users to be able to search through Posts (by title and content, ideally) instantaneously, so after hearing about angular's ability to do this, I gave it a shot.
I have this going on in my posts.js.coffee file:
#PostListCtrl = ($scope, $http) ->
$http.get("posts.json").success (data) ->
$scope.posts = data
And this going on in the JSON doc it references (just to make sure it was working -- which it is).
data =
[
name: "Blog ex"
content: "This is my example post."
,
name: "Test posting"
content: "A different ex post"
,
name: "Test3"
content: "This has some unusual, unique vocabulary."
]
Now all I have left to do is get Rails to save an object (with name/content attributes) in the above JSON file each time a new Post is created, so that the search actually runs through meaningful data. I'm new to Rails/JSON/computer stuff and don't have a clue how to do this. I'm guessing it's in the posts controller, maybe in one of those respond_to blocks, but if anyone could point me to the right way to do this, I'd appreciate it.
If all you want is an instant search, or autocomplete functionality, you should not use Angular.js or any other JS MVC frameworks. Instead, consider using jQuery as #charliefl suggested, it's easy. A simple Ajax call will do it.
JS MVC frameworks are heavy, and you need to design the architecture from the bottom to suit them. Not worthy for such a single functionality.
To make this function work in jQuery, basically:
Listen the event on search box, say typing one or more characters
Catch the characters and use jQuery Ajax to send a POST request to a method in PostsController in Rails, say "search"
Make this method respond to JSON.
Update DOM according to server response.

Resources