Create time entry with custom fields via API
Added by Stanley Rogasik over 5 years ago
Hi,
I'm having trouble creating a time entry via API.
The time entry have few custom fields. I've tried XML and JSON. It still reports that the custom fields are not set.
Here's my body:
<time_entry> <project_id>238</project_id> <user_id>2</user_id> <activity_id>8</activity_id> <hours>7.0</hours> <comments>time entry comment</comments> <spent_on>2012-12-28</spent_on> <custom_fields type="array"> <custom_field id="36"> <value>Zdalna</value> </custom_field> </custom_fields> </time_entry>
Response from redmine:
<?xml version="1.0" encoding="UTF-8"?> <errors type="array"> <error>Typ dniówki nie może być puste</error> <error>Projekt nie może być puste</error> <error>Projekt jest nieprawidłowe</error> <error>Zagadnienie nie może być puste</error> </errors>
I tried everything and it seems that there's not so much alike problems.
Could anybody help me? Or at least show me it's body?
Replies (1)
RE: Create time entry with custom fields via API - Added by Sunding Wei about 5 years ago
I just succeeded to create a time entry with JSON format, for your info
#!/bin/bash KEY='82b61d2c4b7be2e1ccac9dd64f2ebaxxxxxxxxxxxx' curl \ -H "X-Redmine-API-Key:$KEY" \ -H "Content-Type: application/json" \ -X POST \ --data '{"time_entry": {"issue_id": 11274, "hours": 8, "comments": "Test"}}' \ http://172.16.11.211/time_entries.json?project_id=swei&user_id=5