java 调用IPFS出现405

问题描述

代码

public static void main(String[] args) throws IOException {

        IPFS ipfs = new IPFS("/ip4/127.0.0.1/tcp/5001");
//        NamedStreamable.FileWrapper savefile = new NamedStreamable.FileWrapper(new File("D:/test.jpg"));
//        MerkleNode result = ipfs.add(savefile).get(0);

    }
Exception in thread "main" java.lang.RuntimeException: IOException contacting IPFS daemon.
Trailer: null 405 - Method Not Allowed

	at io.ipfs.api.IPFS.get(IPFS.java:683)
	at io.ipfs.api.IPFS.retrieve(IPFS.java:662)
	at io.ipfs.api.IPFS.retrieveAndParse(IPFS.java:624)
	at io.ipfs.api.IPFS.version(IPFS.java:572)
	at io.ipfs.api.IPFS.(IPFS.java:69)
	at io.ipfs.api.IPFS.(IPFS.java:53)
	at io.ipfs.api.IPFS.(IPFS.java:49)
	at IPFStest.main(IPFStest.java:17)
Caused by: java.io.IOException: Server returned HTTP response code: 405 for URL: http://127.0.0.1:5001/api/v0/version
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1894)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
	at io.ipfs.api.IPFS.get(IPFS.java:671)
	... 7 more

 

今天查阅官方文档时发现,5版本以后均不支持。如下是官方的解释

java 调用IPFS出现405_第1张图片

博主已解决,可私聊~~~

你可能感兴趣的:(java后台,区块链)