+ Add Question

Sync API: TempIdMapping

How exactly 'TempIdMapping' works?

I know that I need to manage temporary id's to items that my application generates. And I know also that the API needs to offer a real id instead of the temporary.

But when it happens? When will I receive something from 'TempIdMapping'?

All responses

Brendon Wadey staff
Replied on Aug 16, 2013 - 11:44

Hi Richard,

I have let the devs know about your API question and will update you when I receive a reply.

Thanks,
Brendon.

Amir Salihefendic staff
Replied on Aug 26, 2013 - 10:14

Hi Richard

It works like this:
- Your client uses temporary ids (this is the only way that your client can be offline)
- When you do a sync command to the server you pass along your temporary ids
- The server returns a map linking from temporary ids to real ids. When you receive this map you update your local model so it uses real ids

An example:
- You add an item {"type": "item_add", "temp_id": "$1326468158202", ...}
- The server will return TempIdMapping of {"$1326468158202": 232323}

You can also reference to temporary ids. I.e. instead of passing the real id to item_delete you can pass a temporary id:
{ "type": "item_delete", "timestamp": 1326470379977, "args": { "ids": ["$1326468158202"] } }

Hope this was of help to you.

Regards,
Amir

Richard Lopes premium
Replied on Sep 05, 2013 - 06:10

Ok. Understood. But When It happens? At the response of this request?

Amir Salihefendic staff
Replied on Sep 06, 2013 - 07:05

Hi Richard

Yes, it happens at the response of the request that adds projects, tasks etc.

Regards,
Amir