Hi @Ahmad, in that case you will need to make sure the request is happening outside of the browser.
You can try using something like this as a simple script:
#!/usr/bin/env python3
import requests
ASSET_UID = 'your asset uid'
PK = 123456789 # the id of your submission
TOKEN = 'your secret token'
SERVER_URL = 'kobo.humanitarianresponse.info' # your server URL
def get_request_url():
return f'{SERVER_URL}/api/v2/assets/{ASSET_UID}/data/{PK}/enketo/edit/?return_url=false'
def get_edit_url(request_url):
res = requests.get(request_url, headers={'Authorization': f'Token {TOKEN}'})
data = res.json()
if 'url' in data:
return data['url']
else:
return data['detail']
def main():
request_url = get_request_url()
edit_url = get_edit_url(request_url)
print(edit_url)
if __name__ == '__main__':
main()
You can copy-and-paste this into a file called edit.py
, enter your details at the top and then run it (if you have python installed) like:
python3 edit.py
And it will give you something like:
https://ee.humanitarianresponse.info/edit/wqhDXK3X?instance_id=516510a3-6217-4f12-baa9-16abb528b10e&return_url=false
Or:
Not allowed. Record is already being edited