Example of an Asynchronous Mutator Transaction with nowait=true#
Request:
POST http://172.29.232.238/api/data/Countries/
?hierarchy=[hierarchy]
&nowait=true
Payload of the request:
{'country_name': 'Callback Created Example Country Name',
'request_meta': {'callback_password': 'password',
'callback_url': 'http://localhost:9365',
'callback_username': 'username',
'external_id': '3x4mpl3-3xt3rn4l-7d',
'external_reference': 'External Ref'}}
Synchronous response:
{
href: "/api/tool/Transaction/e6ac7c1e-c63a-11e3-9af5-08002791605b"
success: true
transaction_id: "e6ac7c1e-c63a-11e3-9af5-08002791605b"
}
HTTP 202 ACCEPTED
Asynchronous transaction status callback (console output of the simple http service provided in the separate example section):
POST - 2014-04-17 16:16:43.737509
Headers:
{'accept-encoding': 'identity',
'authorization': 'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
'content-length': '275',
'content-type': 'application/json',
'host': 'localhost:8080'}
Raw Callback Body:
'{"status": "Fail", "transaction":
{"href":
"http://django.testserver/api/tool/Transaction/
34866060-fd47-11e3-88dd-080027880ca6/",
"id": "34866060-fd47-11e3-88dd-080027880ca6"},
"resource": {"hierarchy": "1c0efge2c0deab10da595101",
"model_type": "data/Countries",
"pkid": "53ac3d41c9527062809c0021"},
"external_reference": "External Ref",
"external_id": "3x4mpl3-3xt3rn4l-7d"}'
Pretty Callback Body:
{u'external_id': u'3x4mpl3-3xt3rn4l-7d',
u'external_reference': u'External Ref',
u'resource': {u'hierarchy': u'1c0efge2c0deab10da595101',
u'model_type': u'data/Countries',
u'pkid': u'53ac3d41c9527062809c0021'},
u'status': u'Fail',
u'transaction': {u'href':
u'http://django.testserver/api/tool/Transaction/
34866060-fd47-11e3-88dd-080027880ca6/',
u'id': u'34866060-fd47-11e3-88dd-080027880ca6'}}
localhost - - [17/Apr/2014 16:16:43] "POST / HTTP/1.1" 200 –