testing with curl, issues
See original GitHub issuei added the package to my setup, and tried to test it using curl from the example of https://github.com/jaydenseric/graphql-multipart-request-spec, i guess it should be working. modified a bit.
upload mutation:
class UploadMutation(graphene.Mutation):
class Arguments:
file = Upload(required=True)
success = graphene.Boolean()
def mutate(self, info, file, **kwargs):
# file parameter is key to uploaded file in FILES from context
uploaded_file = info.context.FILES.get(file)
# do something with your file
return UploadMutation(success=True)
class Mutation(graphene.ObjectType):
upload_mutation = UploadMutation.Field()
i did the ModifiedGraphQLView
modification as well.
when i run the current command:
curl http://localhost:8000/graphql -F operations='{ "query": "mutation ($file: Upload!) {
uploadMutation(file: $file) { id } }", "variables": { "file": null } }' -F map='{ "0": ["variables.file"] }' -F 0=@"C:\
Users\William S. Hansen\Documents\upload.txt"
i only changed the mutation name, the uri, and the path to the file.
i get the following error:
Internal Server Error: /graphql
Traceback (most recent call last):
File "C:\Users\William S. Hansen\source\repos\web\PersonalDataApi\PersonalDataApi\env\lib\site-packages\django\core\handlers\exception.py", line 35, in inner
response = get_response(request)
File "C:\Users\William S. Hansen\source\repos\web\PersonalDataApi\PersonalDataApi\env\lib\site-packages\django\core\handlers\base.py", line 128, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Users\William S. Hansen\source\repos\web\PersonalDataApi\PersonalDataApi\env\lib\site-packages\django\core\handlers\base.py", line 126, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\William S. Hansen\source\repos\web\PersonalDataApi\PersonalDataApi\env\lib\site-packages\django\views\generic\base.py", line 69, in view
return self.dispatch(request, *args, **kwargs)
File "C:\Users\William S. Hansen\source\repos\web\PersonalDataApi\PersonalDataApi\env\lib\site-packages\django\utils\decorators.py", line 62, in _wrapper
return bound_func(*args, **kwargs)
File "C:\Users\William S. Hansen\source\repos\web\PersonalDataApi\PersonalDataApi\env\lib\site-packages\django\utils\decorators.py", line 142, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "C:\Users\William S. Hansen\source\repos\web\PersonalDataApi\PersonalDataApi\env\lib\site-packages\django\utils\decorators.py", line 58, in bound_func
return func.__get__(self, type(self))(*args2, **kwargs2)
File "C:\Users\William S. Hansen\source\repos\web\PersonalDataApi\PersonalDataApi\env\lib\site-packages\graphene_django\views.py", line 119, in dispatch
request, data, show_graphiql)
File "C:\Users\William S. Hansen\source\repos\web\PersonalDataApi\PersonalDataApi\env\lib\site-packages\graphene_django\views.py", line 149, in get_response
request, data)
File "C:\Users\William S. Hansen\source\repos\web\PersonalDataApi\PersonalDataApi\env\lib\site-packages\graphene_file_upload\__init__.py", line 47, in get_graphql_params
raise e
File "C:\Users\William S. Hansen\source\repos\web\PersonalDataApi\PersonalDataApi\env\lib\site-packages\graphene_file_upload\__init__.py", line 30, in get_graphql_params
operations = json.loads(operations)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\json\__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\json\decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\json\decoder.py", line 355, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 3 (char 2)
is it the request that is wrong, or what am i not getting?
what is it with those double quotes?
it seems like the curl command is also complaining a bit, from the terminal:
curl: (6) Could not resolve host: ($file
curl: (6) Could not resolve host: Upload!)
curl: (3) [globbing] unmatched brace in column 1
curl: (6) Could not resolve host: uploadMutation(file
curl: (6) Could not resolve host: $file)
curl: (3) [globbing] unmatched brace in column 1
curl: (6) Could not resolve host: id
curl: (3) [globbing] unmatched close brace/bracket in column 1
curl: (3) [globbing] unmatched close brace/bracket in column 1
thanks 😃
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
How to use cURL to Test an Origin Server's Response - Fastly
For our demo purposes, we'll use curl to simulate the browser experience in requesting a webpage. This allows us to have complete control...
Read more >How to troubleshoot network applications with curl - A2 Hosting
Sometimes you need to test connectivity from your local computer. This article describes how to use curl to troubleshoot network ...
Read more >How do I debug latency issues using curl? - Heroku Help
DNS resolution issues The speed of domain name lookups can vary due to several factors. Again, you can test this with curl using...
Read more >Stress Testing with cURL - AG
There are plenty of tools for stress testing, read RapidAPI, paw, SoapUI, Postman, rest-assured, JMeter and so on! I'm sure they are amazing ......
Read more >10 cURL Command Usage with Real-Time Example - Geekflare
You can use curl by inserting a header with your data to test or troubleshoot the particular issue. Let's see the following example...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve been getting
{"errors":[{"message":"Must provide query string."}]}
for the last 2 hours and have been banging my head over this. Turned out it was because I didn’t replaceGraphQLView.as_view
withFileUploadGraphQLView.as_view
inurls.py
(which is described in the README for django integration – in case this may help someone else out there.I made it work. Thanks a lot. I was using the GraphQL, not using the “Multipart form” in insomnia.