无法向Java中经过身份验证的Hyperledger Composer REST服务器发出发布请求 [英] Not able to do a post request to an authenticated Hyperledger Composer rest server in Java

查看:111
本文介绍了无法向Java中经过身份验证的Hyperledger Composer REST服务器发出发布请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法向经过身份验证的Composer rest服务器发出POST请求.

I am not able to do a POST request to the Composer rest server that is authenticated.

  • 我一直在尝试使用Hyperledger composer rest服务器 启用身份验证和多用户.
  • 我已经通过导出启用了基于Github的身份验证 COMPOSER_PROVIDERS变量和多用户模式,以及电子钱包和 身份.
  • 我在github上验证了其余服务器,并且我能够进行休息 Composer Swagger资源管理器中的操作.
  • 我还可以通过传递Postman中的其余操作 带有access_token的网址. http://localhost:4200/api/Trader?access_token = xxxxxxxxxxx .有效 在邮递员中也是如此.
  • I have been trying out Hyperledger composer rest server with authentication and multiuser enabled.
  • I have enabled Github based authentication by exporting COMPOSER_PROVIDERS variable and multiuser mode with Wallet and identities .
  • I authenticate the rest server in github and i am able to do rest operations in the Composer Swagger explorer .
  • I am also able to do the rest operations in Postman by passing the url with the access_token . http://localhost:4200/api/Trader?access_token=xxxxxxxxxxx .This works in Postman as well.

问题是即使将访问令牌作为参数传递后,我也无法从Java代码向作曲家休息URL发出发布请求.我已经尝试过使用OKHttpClient,Apache HTTPClient,java.net客户端,CloseableHTTPClient.

Problem is i am not able to do a post request to the composer-rest URL from java code even after passing the access token as param. I have tried with OKHttpClient,Apache HTTPClient, java.net client , CloseableHTTPClient .

所有给我的就是

Server returned HTTP response code: 401

在所有方法中,我都会收到授权失败"错误.

In all methods i get an "AUTHORIZATION FAILURE" error .

我不知道我是否有任何遗漏,因为我能够从Postman进行休息手术.我从Postman本身获取代码格式,并将其粘贴到Java代码中,但仍然无法正常工作.我不知道我在做什么错,

I dont know if i am missing anything , because i am able to do a rest operation from Postman . I take the code format from Postman itself and paste it in the Java code and it still doesnt work . I dont know what i am doing wrong ,

建议,代码段?

谢谢!

推荐答案

由于您设法从Postman运行此程序,因此您显然在Java代码中缺少了某些内容.

since you managed to get this running from Postman then you're obviously missing something in your java code.

您可能具有正确的URL,但可能缺少标头,json类型或类似的东西.

You probably have the URL correct, but might be missing a header, or a json type or something of the sorts.

检查您的邮递员请求,然后将其准确复制到您的Java代码中,而不只是URL中.

Inspect your Postman request and replicate it exactly in your java code, everything, not just the URL.

保留您的请求日志,并将其与邮递员的日志进行比较,以确切地了解两者之间的区别.

Keep a log of your request and compare it against the Postman one, to see exactly what the difference is.

这篇关于无法向Java中经过身份验证的Hyperledger Composer REST服务器发出发布请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆