Duplicating a project using API

Hi,

I am using API to duplicate a project using python code. Data passed to the API is as below.


data = {"include": [
  "members",
  "notes",
  "task_notes",
  "task_assignee",
  "task_subtasks",
  "task_attachments",
  "task_dependencies",
  "task_followers",
  "task_tags",
  "task_projects"
],
  "name":name,
   "schedule_dates": {
    "due_on": due_on,
    "should_skip_weekends": false,
    "start_on": start_on
},
  "team":team
    }

Below error is displayed.

message

schedule_dates: Value is not an object

Can you please confirm if the above format is correct for setting the values for schedule_dates?

1 Like

Hi @anon45644609,

I can see two issues in terms of this portion of the documentation that discusses project duplication and schedule_dates:

task_dates must be included to use this option. Requires either start_on or due_on , but not both.

First, you haven’t included task_dates. Second, you’ve included both start_on and due_on which isn’t allowed.

Try correcting those two things and see if that helps.

Updated the code as below. Still facing the same issue.

data = {“include”: [
“members”,
“notes”,
“task_notes”,
“task_assignee”,
“task_subtasks”,
“task_attachments”,
“task_dates”,
“task_dependencies”,
“task_followers”,
“task_tags”,
“task_projects”
],
“name”:name,
“schedule_dates”: {
“due_on”: due_on,
“should_skip_weekends”: false
},
“team”:team
}

1 Like

Hmm. I’ve never used the schedule_dates feature of that API endpoint so I’m afraid I can’t be of any help from personal experience.

@Ross_Grambo any ideas here?

Hey @anon45644609,

I tried postman with the below data and it works as expected.

{"data": {
	"include": [
	"members",
	"notes",
	"task_notes",
	"task_assignee",
	"task_subtasks",
	"task_attachments",
	"task_dates",
	"task_dependencies",
	"task_followers",
	"task_tags",
	"task_projects"
	],
	"name": "Example",
	"schedule_dates": {
		"due_on": "2019-05-21",
		"should_skip_weekends": false
	},
	"team": "1234567890"
	}
} 

So I tried python2.7 and python3 with:

job = client.projects.duplicate_project("1234567890", {
        "include": [
            "members",
            "notes",
            "task_notes",
            "task_assignee",
            "task_subtasks",
            "task_attachments",
            "task_dates",
            "task_dependencies",
            "task_followers",
            "task_tags",
            "task_projects"
        ],
        "name": "Example",
        "schedule_dates": {
            "due_on": "2019-05-21",
            "should_skip_weekends": False
        },
        "team": "1234567890"
    }
)

And both of those worked as expected. You should confirm that your variables are turning into strings appropriately.

Hope this helps,
Ross

1 Like

Hi Ross,

Variables are turning into correct string values. I see the issue exists only for the data that is inside the paranthesis { }.

“schedule_dates”: {
“due_on”: “2019-05-21”,
“should_skip_weekends”: False
}

If I remove schedule_dates parameter then the project gets created. I am using ZAP application and using python code inside ZAP.

@anon45644609,

Is ZAP short for Zapier? If so, you’ll need to reach out to them to debug this, as it’s not an issue in our code.

Yes, Ross. It is Zapier.

I have already logged a ticket with Zapier and they had asked for log from POSTMAN for successful call.

I’d recommend using the body I gave earlier ^ and doing the postman call so you can share the logs with them. You’ll be hitting the https://app.asana.com/api/1.0/projects/{project_gid}/duplicate endpoint, and you’ll need to set an Authorization header to “Bearer {your_PAT}”.

Yes, Ross. I have already shared the POSTMAN log with them.

1 Like

Hi,

I have a template with tags. When duplicating that template I would like to keep tasks that are specific tag.

For example, I have a template with Task A,B,C with following tags;

Task-A has “Red, Orange, Pink” as a tag
Task-B has “Red, Blue” as a tag
Task-C has “Blue, Yellow” as a tag

My goal is to duplicate my template regarding “Red” tag and only keep “Task-A” and "Task-B"on my new project.

Is it possible with this code?
Code=> “task_tags”:“Red”

Hi @Dogancan_Ulug!

First, just to clarify, you’ve posted in the Developers & API section which is for developers writing code to interact with Asana, but are you asking about using the POST /projects/{project_gid}/duplicate API endpoint, or your question is not related to coding but rather the product “Duplicate” option in the Asana UI?

Although, in the end the answer is the same, which is no, there’s no capability in either duplication functionality to only duplicate a certain subset of tasks.

You would have to write code to manually do the duplication using the API.

Hi @Phil_Seeman,

My question was duplicating a project by using Asana POST API, not UI.

I am using Microsoft Power Automate for duplicating different templates(32 different templates) with POST API every time. However, I want to have one master template and duplicate template and filter among their custom fields by POST API.

So, I am trying to push parameters to API and filter necessary tasks when I want to duplicate from the master template. As I told you, I am using Power Automate for coding.

PS: Currently I have 32 templates with 50 tasks. For future, I will have 400 tasks as a master template and trying to filter 50 tasks by custom fields.