
[Fetch Request] Trying to set block in POST request
ArsiTheFox opened this issue · 3 comments
Issue type:
- ❓ Question
Question:
I am trying to simply set the block to stone on a display using a JavaScript fetch POST request to ID 3 and it seems not to be working.... I am in version 1.21.1
fetch("http://localhost:3000/networkElement/integratedrest/http/3",{ method:"POST", headers:{ ["Content-Type"]:"application/json" }, body: JSON.stringify({ value:{ "@type": "ValueBlock", resourceLocation:"minecraft:stone" } }) })
I even tried the command from the WIKI but I get the same MC error:
curl -X POST -d "{ \"value\": { \"@type\": \"ValueBlock\", \"resourceLocation\": \"minecraft:stone\"} }" http://localhost:3000/networkElement/integratedrest/http/3
The request gets sent but causes a MC error and just keeps pending:
Am I doing something wrong???
ERROR:
java.lang.NullPointerException: Cannot invoke "com.google.gson.JsonElement.getAsString()" because the return value of "com.google.gson.JsonObject.get(String)" is null
[18Mar2025 05:33:28.665] [nioEventLoopGroup-5-17/WARN] [io.netty.channel.DefaultChannelPipeline/]: An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception. java.lang.NullPointerException: Cannot invoke "com.google.gson.JsonElement.getAsString()" because the return value of "com.google.gson.JsonObject.get(String)" is null at TRANSFORMER/[email protected]/org.cyclops.integratedrest.json.ValueTypeJsonHandlers$8.handleUnchecked(ValueTypeJsonHandlers.java:197) ~[integratedrest-1.21.1-neoforge-1.1.13-138.jar%23377!/:1.1.13] at TRANSFORMER/[email protected]/org.cyclops.integratedrest.json.ValueTypeJsonHandlers$8.handleUnchecked(ValueTypeJsonHandlers.java:185) ~[integratedrest-1.21.1-neoforge-1.1.13-138.jar%23377!/:1.1.13] at TRANSFORMER/[email protected]/org.cyclops.integratedrest.json.handler.CheckedValueTypeJsonHandlerBase.handle(CheckedValueTypeJsonHandlerBase.java:20) ~[integratedrest-1.21.1-neoforge-1.1.13-138.jar%23377!/:1.1.13] at TRANSFORMER/[email protected]/org.cyclops.integratedrest.json.JsonUtil.jsonToValue(JsonUtil.java:210) ~[integratedrest-1.21.1-neoforge-1.1.13-138.jar%23377!/:1.1.13] at TRANSFORMER/[email protected]/org.cyclops.integratedrest.http.request.handler.ElementHttpRequestHandler.handleElement(ElementHttpRequestHandler.java:50) ~[integratedrest-1.21.1-neoforge-1.1.13-138.jar%23377!/:1.1.13] at TRANSFORMER/[email protected]/org.cyclops.integratedrest.http.request.handler.ElementTypeRequestHandler.handle(ElementTypeRequestHandler.java:34) ~[integratedrest-1.21.1-neoforge-1.1.13-138.jar%23377!/:1.1.13] at TRANSFORMER/[email protected]/org.cyclops.integratedrest.http.HttpServerHandler.channelRead0(HttpServerHandler.java:79) ~[integratedrest-1.21.1-neoforge-1.1.13-138.jar%23377!/:1.1.13] at MC-BOOTSTRAP/[email protected]/io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99) ~[netty-transport-4.1.97.Final.jar%23130!/:4.1.97.Final] at MC-BOOTSTRAP/[email protected]/io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[netty-transport-4.1.97.Final.jar%23130!/:4.1.97.Final] at MC-BOOTSTRAP/[email protected]/io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.97.Final.jar%23130!/:4.1.97.Final] at MC-BOOTSTRAP/[email protected]/io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.97.Final.jar%23130!/:4.1.97.Final] at MC-BOOTSTRAP/[email protected]/io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) ~[netty-codec-4.1.97.Final.jar%23132!/:4.1.97.Final] at MC-BOOTSTRAP/[email protected]/io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[netty-transport-4.1.97.Final.jar%23130!/:4.1.97.Final] at MC-BOOTSTRAP/[email protected]/io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.97.Final.jar%23130!/:4.1.97.Final] at MC-BOOTSTRAP/[email protected]/io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.97.Final.jar%23130!/:4.1.97.Final] at MC-BOOTSTRAP/[email protected]/io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346) ~[netty-codec-4.1.97.Final.jar%23132!/:4.1.97.Final] at MC-BOOTSTRAP/[email protected]/io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:318) ~[netty-codec-4.1.97.Final.jar%23132!/:4.1.97.Final] at MC-BOOTSTRAP/[email protected]/io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[netty-transport-4.1.97.Final.jar%23130!/:4.1.97.Final] at MC-BOOTSTRAP/[email protected]/io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.97.Final.jar%23130!/:4.1.97.Final] at MC-BOOTSTRAP/[email protected]/io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.97.Final.jar%23130!/:4.1.97.Final] at MC-BOOTSTRAP/[email protected]/io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[netty-transport-4.1.97.Final.jar%23130!/:4.1.97.Final] at MC-BOOTSTRAP/[email protected]/io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440) ~[netty-transport-4.1.97.Final.jar%23130!/:4.1.97.Final] at MC-BOOTSTRAP/[email protected]/io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.97.Final.jar%23130!/:4.1.97.Final] at MC-BOOTSTRAP/[email protected]/io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[netty-transport-4.1.97.Final.jar%23130!/:4.1.97.Final] at MC-BOOTSTRAP/[email protected]/io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) ~[netty-transport-4.1.97.Final.jar%23130!/:4.1.97.Final] at MC-BOOTSTRAP/[email protected]/io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788) ~[netty-transport-4.1.97.Final.jar%23130!/:4.1.97.Final] at MC-BOOTSTRAP/[email protected]/io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724) ~[netty-transport-4.1.97.Final.jar%23130!/:4.1.97.Final] at MC-BOOTSTRAP/[email protected]/io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650) ~[netty-transport-4.1.97.Final.jar%23130!/:4.1.97.Final] at MC-BOOTSTRAP/[email protected]/io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562) ~[netty-transport-4.1.97.Final.jar%23130!/:4.1.97.Final] at MC-BOOTSTRAP/[email protected]/io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[netty-common-4.1.97.Final.jar%23179!/:4.1.97.Final] at MC-BOOTSTRAP/[email protected]/io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.97.Final.jar%23179!/:4.1.97.Final] at MC-BOOTSTRAP/[email protected]/io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.97.Final.jar%23179!/:4.1.97.Final] at java.base/java.lang.Thread.run(Unknown Source) [?:?]
Someone will answer your question soon. In the meantime, you might be able to get help more quickly on our Discord server.