Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
erp5
Commits
0b116cd9
Commit
0b116cd9
authored
Jun 24, 2024
by
Titouan Soulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_jio_connector: properly handle errors
parent
7e2d3e96
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
bt5/erp5_jio_connector/DocumentTemplateItem/portal_components/document.erp5.JioApiConnector.py
...teItem/portal_components/document.erp5.JioApiConnector.py
+11
-3
No files found.
bt5/erp5_jio_connector/DocumentTemplateItem/portal_components/document.erp5.JioApiConnector.py
View file @
0b116cd9
...
...
@@ -53,11 +53,19 @@ class JioApiConnector(XMLObject):
user_credentials
=
(
self
.
getUserId
(),
self
.
getPassword
())
r
=
requests
.
post
(
get_url
,
json
=
request_dict
,
auth
=
user_credentials
)
if
r
.
status_code
not
in
[
200
,
201
]:
return
None
# Return response when status code is as expected
if
r
.
status_code
in
[
200
,
201
]:
return
r
.
json
()
# Try to get an error message by parsing JSON
result
=
None
try
:
result
=
r
.
json
()
except
:
raise
Exception
(
"Error when sending to API ({}): API returned invalid JSON"
.
format
(
r
.
status_code
))
raise
Exception
(
"Error when sending to API ({}): {}"
.
format
(
r
.
status_code
,
result
[
"message"
]))
def
getFromApi
(
self
,
request_dict
):
return
self
.
_sendToApi
(
"/get"
,
request_dict
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment