# Unable to create task linked to user story

**URL:** https://community.taiga.io/t/unable-to-create-task-linked-to-user-story/2673
**Category:** Troubleshooting
**Created:** [February 21, 2024, 5:11pm UTC](https://community.taiga.io/t/unable-to-create-task-linked-to-user-story/2673 "2024-02-21T17:11:51Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Komarovo](https://avatars.discourse-cdn.com/v4/letter/k/ce7236/32.png) [@Komarovo](https://community.taiga.io/u/Komarovo)
#### Post date: [February 21, 2024, 5:11pm UTC](https://community.taiga.io/t/unable-to-create-task-linked-to-user-story/2673/1 "2024-02-21T17:11:51Z")

</div>

Greetings! I am having issues creating a task linked to a user story via the Taiga API.

> **My Code**
>
> ```auto
> headers = {
> 'Content-Type': 'application/json',
> 'Authorization': 'Bearer ' + auth_request["auth_token"],
> }
> 
> json_data = {
> 'project': 1,
> 'user_story': 324,
> 'subject': 'Test'  
> }
> 
> response = requests.post('http://my.url:9000/api/v1/tasks', headers=headers, json=json_data)
> 
> ```

Here is the issue the error I am receiving:

```auto
{'user_story': ["Invalid pk '324' - object does not exist."]}

```

What I am guessing this means is that it is unable to find the according user story. This confuses me because there is a user story with that id on project 1. I cannot figure out why this is happening.

I have already tried listing out all user stories on that project but I did not find the user story I was looking for.

I does work if I leave out that the user story parameter.

Any help is much appreciated!

---

<div class="post-metadata">

### Author: ![david.barragan](https://dub1.discourse-cdn.com/flex017/user_avatar/community.taiga.io/david.barragan/32/293_2.png) [@david.barragan](https://community.taiga.io/u/david.barragan)
#### Post date: [February 21, 2024, 6:18pm UTC](https://community.taiga.io/t/unable-to-create-task-linked-to-user-story/2673/2 "2024-02-21T18:18:38Z")

</div>

Hi @Komarovo

One user story have two identifiers, the `id` (or pk) and the `ref`:

- `ref` is the value that every user see in the Taiga interface. The ref is a value that is generated from a sequence for each project. It starts at 1, is incremental and is shared by all elements (user stories, tasks, issues and epics) of a project. If `#1` is from an issue, there will be no other object that uses that value in that project. This value is not a valid identifier in the taiga api.

- `id` (or pk): Is a global identifier of an element, generated from a sequence unique to that type of element within the entire Taiga domain. It is the identifier used in the api.

So you have to use ids instead of refs in your calls.

 ![image](https://europe1.discourse-cdn.com/flex017/uploads/taiga/original/2X/d/d96cb3fe2bb3e76a21b6c3be9bc5a7e43bdc1630.png)

I hope this can help.

---

<div class="post-metadata">

### Author: ![Komarovo](https://avatars.discourse-cdn.com/v4/letter/k/ce7236/32.png) [@Komarovo](https://community.taiga.io/u/Komarovo)
#### Post date: [February 21, 2024, 8:24pm UTC](https://community.taiga.io/t/unable-to-create-task-linked-to-user-story/2673/3 "2024-02-21T20:24:49Z")

</div>

That worked. Big thanks!

I guess I just did not do enough research.

I am still confused why the user story did not show up when listing all of the project. Works now, so does not matter.

---

<div class="post-metadata">

### Author: ![david.barragan](https://dub1.discourse-cdn.com/flex017/user_avatar/community.taiga.io/david.barragan/32/293_2.png) [@david.barragan](https://community.taiga.io/u/david.barragan)
#### Post date: [February 21, 2024, 8:36pm UTC](https://community.taiga.io/t/unable-to-create-task-linked-to-user-story/2673/4 "2024-02-21T20:36:15Z")

</div>

Your are welcome

Remember that API list endpoints are paginated so you only show the first ¿100? stories. You can show the documentation about API pagination here: [Taiga REST API](https://docs.taiga.io/api.html#_pagination)
