招摇:python请求:javax.ws.rs文件.NotAllowedException:不允许HTTP 405方法

2024-09-29 23:33:24 发布

您现在位置:Python中文网/ 问答频道 /正文

抱歉,如果这是多余的错误,但我正在寻找一个具体的解决方案。你知道吗

我正在尝试使用swaggerrestapi将模式的新版本发布到Hortonworks模式注册表。我使用python请求模块以编程方式发布新版本。你知道吗

path = '/' + schemaname + '/versions' + '/' + str(max(versions)+1)
logger.info(self.url(path))
requests.post(self.url(path), schemaText)


ERROR  [2019-02-15 17:18:13.496] [dw-167124 - PUT /api/v1/schemaregistry/schemas/diff%20data/versions/2] c.h.r.c.GenericExceptionMapper -  Got exception: [NotAllowedException] / message [HTTP 405 Method Not Allowed] 

我尝试了“Method allowed exception”上前面的问题所建议的各种方法,比如使用PUT、POST或GET。但都没用。使用restapi编程将schema的新版本发布到hdf注册表的正确方法是什么?你知道吗


Tags: path方法self版本urlput注册表编程
1条回答
网友
1楼 · 发布于 2024-09-29 23:33:24

在源代码中,它是@POST @Path("/schemas/{name}/versions")

您需要删除最后的版本号,因为它会返回一个版本。你没有给一个模式一个特定的版本

我不知道是否允许使用空格,所以您可能希望将其从diff data中删除

用于@GET @Path("/schemas/{name}/versions/{version}")的地址不允许使用其他HTTP方法


引用-https://github.com/hortonworks/registry/blob/HDF-2.1.0.0/schema-registry/rest-service/src/main/java/com/hortonworks/registries/schemaregistry/webservice/SchemaRegistryResource.java#L219

注意:您可以使用swagger-codegen为服务器创建Python代码,而不是在requests中重新编写代码

相关问题 更多 >

    热门问题