Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Connection to Add Set Throws Error 500 when initiated with N8N #221

Open
nickgabbard opened this issue Mar 9, 2023 · 4 comments
Open
Labels
bug Something isn't working

Comments

@nickgabbard
Copy link

Is your feature request related to a problem? Please describe.
I have an inventory and sales management system for my farm. I am attempting to automatically create sets/jobs for orders as they arrive using an automation tool called N8N that can be triggered from Shopify.

I am having trouble deciphering the octoprint.log entries that are generated when trying to add a set via the API using an automation package known as N8N.

When attempting to use the plugin/continuousprint/set/add endpoint, I'm getting a 500 error and I can't figure out what I'm doing wrong.

Relevant section of octoprint.log
2023-03-09 21:56:05,281 - octoprint - ERROR - Exception on /plugin/continuousprint/set/add [POST]
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 2073, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1519, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1517, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1503, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
File "/octoprint/plugins/lib/python3.8/site-packages/octoprint/server/util/flask.py", line 1575, in decorated_view
return no_firstrun_access(flask_login.login_required(func))(*args, **kwargs)
File "/octoprint/plugins/lib/python3.8/site-packages/octoprint/server/util/flask.py", line 1598, in decorated_view
return func(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/flask_login/utils.py", line 272, in decorated_view
return func(*args, **kwargs)
File "/octoprint/plugins/lib/python3.8/site-packages/continuousprint/api.py", line 88, in cpq_permission_wrapper
return func(*args, **kwargs)
File "/octoprint/plugins/lib/python3.8/site-packages/continuousprint/api.py", line 190, in add_set
data = self._preprocess_set(dict(**flask.request.form))
File "/octoprint/plugins/lib/python3.8/site-packages/continuousprint/plugin.py", line 222, in _preprocess_set
data["path"],
KeyError: 'path'

I can use the get endpoint that shows me the state of the queues, so I'm confident it's not an authentication or access issue.

Details of the request I'm trying to send:
Screenshot 2023-03-09 171051

Send Query Parameters: No
Send Headers: No
Send Body: Yes
Body Content Type: JSON
Specify Body: Using JSON
JSON: {"path":"4off.gcode","sd":false,"count":1,"jobName":"Test Job","job":""}

Notes: We don't use SD cards, and I have confirmed that 4off.gcode exists in the uploads folder.
Screenshot 2023-03-09 171306

This is the response I'm getting:
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

Describe the solution you'd like
I would like to know are there other places to look to see what data is being passed to the API.

Describe alternatives you've considered
None yet.

Additional context
Is there something boneheaded I'm missing?

@nickgabbard
Copy link
Author

I just realized this should probably be a discussion thread instead of an issue. My bad.

@smartin015
Copy link
Owner

No worries, thanks for posting! In fact, could you do me a favor and weigh in on #57 when you've landed on a useful setup? I'd love to have a blessed - or at least functional - set of steps for integrating inventory management.

This and this may be of use to you - it should work with either a JSON or form-style post request, but you might try the latter just to see if it unsticks anything. (source code for reference)

HTH

@nickgabbard
Copy link
Author

Ok, so passing the data as a form style post did the trick, but straight JSON did not work for some reason.

@smartin015 smartin015 added the bug Something isn't working label Mar 10, 2023
@smartin015
Copy link
Owner

Ok, so passing the data as a form style post did the trick, but straight JSON did not work for some reason.

Good to know. Let's leave this bug open for now; I'll investigate before closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants