How to set header in httppost/ httpget request

前端 未结 2 1719
失恋的感觉
失恋的感觉 2021-01-06 22:37

i have a web service like \" post -H \'Authorization: Token token=\"2hwhdh443hdhfh43j3jdej3j3\"\'. how to set this header in httpPost/ get request.

My code is here-<

相关标签:
2条回答
  • 2021-01-06 22:47

    You do just silly mistake. Just do this.

    Replace this :-

     request.setHeader(new BasicHeader("Authorization: Token","token= 2hwhdh443hdhfh43j3jdej3j3"));
    

    To this :-

     request.setHeader(new BasicHeader("Authorization: Token","2hwhdh443hdhfh43j3jdej3j3"));
    

    Hope this will help. :)

    0 讨论(0)
  • 2021-01-06 23:01

    Try removing "Content-Type" header and modify "Authorization" to -

    request.addHeader("Authorization","Token token=2hwhdh443hdhfh43j3jdej3j3");
    

    Working for me.

    0 讨论(0)
提交回复
热议问题