Re: Curl PUT Request With JWT Authorization Header

2016-08-23 Thread Peter Boyles
Hi Andrew,

I tried that call and got this strange message:

HTTP/1.1 500 INTERNAL SERVER ERROR
Connection: keep-alive
Content-Type: text/html
Date: Tue, 23 Aug 2016 13:15:20 GMT
Server: gunicorn/19.6.0
Transfer-Encoding: chunked
Vary: Cookie
Via: 1.1 vegur
X-Frame-Options: SAMEORIGIN


http: error: ChunkedEncodingError: ('Connection broken: IncompleteRead(2785 
bytes read, 7455 more expected)', IncompleteRead(2785 bytes read, 7455 more 
expected))

Enter code here...



On Monday, August 22, 2016 at 10:26:20 PM UTC-5, Andrew Backer wrote:
>
> Try using the `httpie` utility, you'll find it _much_ less of a pain in 
> the ass than `curl`.  Gave up on that ages ago. 
>
> ```
> pip install httpie
> export TOKEN=`get token value`
> http put url.com/route/ field=value Authorization:"JWT $TOKEN"
> ```
>
> As for the Curl line, it looks fine to me, i don't see anything obviously 
> wrong.  is the "-" in "-H" the right dash? 
>
> bit.io.c...@gmail.com 
> August 23, 2016 at 5:44 AM
>
> I am still getting a hang of using curl for testing API request from the 
> terminal. I have a particular issue with formatting because the API request 
> I am attempting requires a JWT Token to be passed with every call. The 
> request I am attempting to pass is PUT request and my question is where to 
> place the header for the JWT token authorization. I have tried the 
> following format and I get a error Could not resolve host: —H curl: (6) 
> Could not resolve host: Authorization:
>
>
> curl -X PUT -H "Authorization: JWT " -d "field=value" "
> https://url/update_record//"
>  
>
> Any ideas?
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django REST framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-rest-framework+unsubscr...@googlegroups.com .
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


3.4.6 Release

2016-08-23 Thread Tom Christie
3.4.6 has now been released.
Includes a few more bugfixes, including a regression in the browsable API.

Release notes available 
here: http://www.django-rest-framework.org/topics/release-notes/#34x-series

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Curl PUT Request With JWT Authorization Header

2016-08-23 Thread 'voger' via Django REST framework
Personally I prefer "postman rest client". Much less trouble bout since 
you insist going CLI here is the notes file from 
codingforentrepreneurs.com course on django Rest Framework.


They have it open in github and I think this particular line might 
interest you.


https://github.com/codingforentrepreneurs/srvup-rest-framework/blob/master/src/srvup/api_curl_tests.py#L30

On 23/08/2016 12:44 πμ, bit.io.consult...@gmail.com wrote:

I am still getting a hang of using curl for testing API request from the
terminal. I have a particular issue with formatting because the API
request I am attempting requires a JWT Token to be passed with every
call. The request I am attempting to pass is PUT request and my question
is where to place the header for the JWT token authorization. I have
tried the following format and I get a error Could not resolve host: —H
curl: (6) Could not resolve host: Authorization:


|curl -X PUT -H "Authorization: JWT " -d "field=value"
"https://url/update_record//"
 |

Any ideas?

--
You received this message because you are subscribed to the Google
Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-rest-framework+unsubscr...@googlegroups.com
.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Django 
REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Curl PUT Request With JWT Authorization Header

2016-08-23 Thread 'voger' via Django REST framework

BTW the error you get it doesn't have to do with the authorization.
It says that it can't resolve the url.

Is the url you posted the actual url that you are trying? It doesn't 
seem right.


On 23/08/2016 09:06 μμ, 'voger' via Django REST framework wrote:

Personally I prefer "postman rest client". Much less trouble bout since
you insist going CLI here is the notes file from
codingforentrepreneurs.com course on django Rest Framework.

They have it open in github and I think this particular line might
interest you.

https://github.com/codingforentrepreneurs/srvup-rest-framework/blob/master/src/srvup/api_curl_tests.py#L30


On 23/08/2016 12:44 πμ, bit.io.consult...@gmail.com wrote:

I am still getting a hang of using curl for testing API request from the
terminal. I have a particular issue with formatting because the API
request I am attempting requires a JWT Token to be passed with every
call. The request I am attempting to pass is PUT request and my question
is where to place the header for the JWT token authorization. I have
tried the following format and I get a error Could not resolve host: —H
curl: (6) Could not resolve host: Authorization:


|curl -X PUT -H "Authorization: JWT " -d "field=value"
"https://url/update_record//"
 |

Any ideas?

--
You received this message because you are subscribed to the Google
Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-rest-framework+unsubscr...@googlegroups.com
.
For more options, visit https://groups.google.com/d/optout.




--
You received this message because you are subscribed to the Google Groups "Django 
REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


working ImageField upload example

2016-08-23 Thread ggilley
I'm ready to tear my hair out. I've been searching and searching for a 
working example of uploading to django using rest apis.

I've looked at a lot of examples I've found searching, but none of them 
seem to work.

Do multipart forms work in the current version? I never get any of the 
parameters across. JSON seems to work fine, but file uploading doesn't work 
with JSON.

Any help would be greatly appreciated.

  Greg



-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: working ImageField upload example

2016-08-23 Thread Jeff Tchang
Here is what I have inside viewsets.py



from rest_framework.parsers import MultiPartParser, FormParser,
FileUploadParser

class CustomMultiPartParser(MultiPartParser):
media_type = 'multipart/*'

class PictureViewSet(viewsets.ModelViewSet):
queryset = Picture.objects.all().order_by('-created')
serializer_class = PictureSerializer
permission_classes = [PicturePermission]
parser_classes = (CustomMultiPartParser, FormParser, FileUploadParser)

def create(self, request):
response = super(PictureViewSet, self).create(request)
return response

On Tue, Aug 23, 2016 at 9:45 PM,  wrote:
>
> I'm ready to tear my hair out. I've been searching and searching for a
working example of uploading to django using rest apis.
>
> I've looked at a lot of examples I've found searching, but none of them
seem to work.
>
> Do multipart forms work in the current version? I never get any of the
parameters across. JSON seems to work fine, but file uploading doesn't work
with JSON.
>
> Any help would be greatly appreciated.
>
>   Greg
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
"Django REST framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an
email to django-rest-framework+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: working ImageField upload example

2016-08-23 Thread Andrew Backer

Greg,


Yes, file uploading doesn't work in JSON.  It is theoretically possible, 
but don't try :D


Multipart works fine here, and we have many several ViewSets and Views 
that receive images.  We haven't even customized anything except by 
adding a function to de-nest the json values (e.g. user { name } =>  
user.name) for the field values when posting between services.


What is the exact issue you are having?  Perhaps the response json or a 
picture of the crash?



ggil...@gmail.com 
August 24, 2016 at 12:45 PM
I'm ready to tear my hair out. I've been searching and searching for a 
working example of uploading to django using rest apis.


I've looked at a lot of examples I've found searching, but none of 
them seem to work.


Do multipart forms work in the current version? I never get any of the 
parameters across. JSON seems to work fine, but file uploading doesn't 
work with JSON.


Any help would be greatly appreciated.

  Greg



--
You received this message because you are subscribed to the Google 
Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to django-rest-framework+unsubscr...@googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Django 
REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.