繁体   English   中英

在Rest API中为HTTP GET请求设置的标头是什么

[英]What are the headers to set in the Rest API for the HTTP GET request

@api_view(['GET'])
def gatewayentities_list(request,format=None):
    requestMeta = request.META
    if ('HTTP_AUTHORIZATION' not in requestMeta.keys()):
        return JSONResponse({"status": "UNAUTHORIZED"}, status=401)
    elif (requestMeta['HTTP_AUTHORIZATION'] is not None):
        headerParameters = requestMeta['HTTP_AUTHORIZATION'].split(" ")
        companyid_id = headerParameters[2]
        apikey = headerParameters[0]
        userId = headerParameters[3]
        try:
            applicationid = int(headerParameters[4])
        except IndexError:
            applicationid = 0

{'Transfer-Encoding':'chunked','Vary':'Cookie','Server':'Apache / 2.2.29(Amazon)','Connection':'close','Date':'Wed,06 2018年6月6:50:09 GMT'','Content-Type':'text / html; charset = UTF-8'}

Server Error (500)

任何帮助,将不胜感激!

您收到的错误似乎与请求映射标头无关。

您的请求映射方法应类似于:

@RequestMapping(produces = "application/json", method = RequestMethod.GET, value = "data")
public @ResponseBody ResponseEntity<?> gatewayentities_list(@ModelAttribute ,BindingResult errors, HttpServletRequest request, HttpServletResponse response){
// your code.
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM