question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cleaner way to submit/cancel documents via REST

See original GitHub issue

Refer: https://github.com/frappe/frappe_docs/pull/221

Often in the community, this is recommended for cancelling/submitting:

PUT /api/resource/doctype/name 
{"docstatus": 2}

If you read document.py this isn’t really equivalent to cancelling the document. IMO the current best method is to supply run_method (both submit/cancel are whitelisted).

Current method that works well is:

POST /api/resource/:doctype/:name
# body
{ "run_method": "submit" }

That’s ugly and returns null 💩

Proposals

  1. Fix document.py so just sending PUT request with new docstatus works. (this we should do regardless of # 2)
  2. Provide a cleaner API for submit/cancel (or all methods that work with run_method)?

I suggested something like this in docs PR:

POST /api/resource/doctype/name/cancel

cc: @gavindsouza @surajshetty3416 @netchampfaris @sagarvora @barredterra

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:8
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ankushcommented, Nov 29, 2021

@ankush i would rather disallow naming series containing /. This causes lots of other issue, for example when switching between form and print view.

Sadly lots of users do use naming series with / in them.

Maybe name part of URL should be urlencoded (/ -> %2F) @surajshetty3416 ?

1reaction
ankushcommented, Nov 27, 2021

Proposal of POST /api/resource/doctype/name/cancel will have to be scrapped because I can’t think of any decent way to split URL that will respect naming series containing / 🥲

We can hardcode few methods like cancel/submit maybe? split URL and check if last part matches one of the supported method?

Sent PR for fixing rest of the issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Working with folders and files with REST - Microsoft Learn
Perform basic create, read, update, and delete (CRUD) operations on folders and files with the SharePoint REST interface.
Read more >
How to upload attachments via REST API - Jama Community
1. How to upload attachments via REST API -- a step-by-step python script. ; 'content-type': "application/json" ; "https://" + company_name + " ...
Read more >
Proper way to implement RESTful large file upload
I've found the procedure works very well for handling large file uploads in REST APIs and facilitates the handling of the many edge...
Read more >
hyperx cancel order
We can use the Set-VMDVDDrive PowerShell command to attach an ISO file to a virtual ... The best way to access combo boxes...
Read more >
Using REST Services to upload and download files
On the top of that, we will show how to build a JUnit Test to test files uploading using RESTEasy Client API. Uploading...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found