[Bug]: REST.post throws an exception on execution
Describe the Bug
I have this macro:
[h:baseUrl = getLibProperty("baseUrl")]
[h:apiKey = getLibProperty("apiKey")]
[h:mediaType = "application/json; charset=utf-8"]
[h:data = json.get(macro.args, "data")]
[h:id = json.get(data, "id")]
[h:headers = json.set("{}", "X-API-Key", json.append("", apiKey))]
[h:response = REST.post(baseUrl + id, data, mediaType, headers, 0)]
[h:broadcast("<pre>" + json.indent(response, 2) + "</pre>")]
I use it to call an API of my own with a JSON object. This works, the JSON is updated nicely on the server, but I do still receive an exception in MapTool.
java.lang.NullPointerException: Parameter specified as non-null is null: method okhttp3.MediaType$Companion.parse, parameter error executing expression response = REST.post(baseUrl + id, data, mediaType, headers, 0).
Error trace : processor@lib:REST <<< macroLink
Originally, the endpoint returned a 204, and thinking it might be that MapTool expected a 200, I tried changing it to 200. I have tried returning an empty 200 and one with a string content.
I still get the exception, so apparently there is an issue with the Java code handling the return response, since the call goes through fine.
To Reproduce
- Set up a rest API with a POST endpoint.
- Call it with
REST.postand some data. - Observe the exception.
I have attached the lib token for good measure, but since it is pretty purpose built I am unsure if it will help. It is a .rptok, but renamed to .zip.
Expected Behaviour
I expect the current behavior except the exception.
Screenshots
No response
MapTool Info
1.17.1
Desktop
Windows 11 Home
Additional Context
Debug information from MapTool:
==== MapTool Information ====
MapTool Version: 1.17.1
MapTool Home...: C:\Users\thoma\.maptool-rptools
MapTool Install: C:\Users\thoma\AppData\Local\MapTool\1.17.1\app
Max mem avail..: 7 GB
Max mem used...: 628 MB
Custom Property: -DMAPTOOL_LOGDIR=C:\Users\thoma\.maptool-rptools\logs
Custom Property: -DMAPTOOL_DATADIR=.maptool-rptools
==== Java Information ====
Java Home......: C:\Users\thoma\AppData\Local\MapTool\1.17.1\runtime
Java Vendor....: Eclipse Adoptium
Java Version...: 21.0.1
Java Parameters:
-Djpackage.app-version=1.0
-Xss8M
-Dsun.java2d.d3d=false
-Dsentry.environment=Production
-Dfile.encoding=UTF-8
-Dpolyglot.engine.WarnInterpreterOnly=false
-Djava.util.Arrays.useLegacyMergeSort=true
-XX:+ShowCodeDetailsInExceptionMessages
--add-opens=java.desktop/java.awt=ALL-UNNAMED
--add-opens=java.desktop/java.awt.geom=ALL-UNNAMED
--add-opens=java.desktop/sun.awt.geom=ALL-UNNAMED
--add-opens=java.base/java.util=ALL-UNNAMED
--add-opens=javafx.web/javafx.scene.web=ALL-UNNAMED
--add-opens=javafx.web/com.sun.webkit=ALL-UNNAMED
--add-opens=javafx.web/com.sun.webkit.dom=ALL-UNNAMED
--add-opens=java.desktop/javax.swing=ALL-UNNAMED
--add-opens=java.desktop/sun.awt.shell=ALL-UNNAMED
--add-opens=java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED
-Djpackage.app-path=C:\Users\thoma\AppData\Local\MapTool\1.17.1\MapTool.exe
==== OS Information ====
OS Name........: Windows 11
OS Version.....: 10.0
OS Architecture: amd64
Processor......: AMD64 Family 25 Model 80 Stepping 0, AuthenticAMD
PATH...........: C:\Users\thoma\AppData\Local\MapTool\1.17.1;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Python313\Scripts\;C:\Python313\;C:\Program Files\Eclipse Adoptium\jdk-21.0.2.13-hotspot\bin;C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot\bin;C:\Program Files\Eclipse Adoptium\jdk-17.0.4.8-hotspot\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\dotnet\;C:\Program Files (x86)\WinMerge;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\dotnet\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git LFS;C:\Program Files\TortoiseGit\bin;C:\Program Files\NVIDIA Corporation\NVIDIA app\NvDLISR;C:\Program Files\Calibre2\;C:\Program Files (x86)\Microsoft SQL Server\160\DTS\Binn\;C:\Program Files\Docker\Docker\resources\bin;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Program Files\PowerShell\7\;C:\Users\thoma\AppData\Local\Microsoft\WindowsApps;;C:\Users\thoma\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\thoma\.dotnet\tools;C:\Users\thoma\AppData\Local\JetBrains\Toolbox\scripts;C:\Users\thoma\AppData\Local\Programs\Fiddler;C:\Users\thoma\.dotnet\tools;C:\Users\thoma\AppData\Local\Microsoft\WindowsApps;C:\Users\thoma\AppData\Local\Microsoft\WinGet\Packages\nektos.act_Microsoft.Winget.Source_8wekyb3d8bbwe;C:\Users\thoma\AppData\Roaming\npm;C:\Users\thoma\AppData\Local\MapTool\1.17.1\app;.
Number of Procs: 12
==== User Information ====
User Name: thoma
User Home: C:\Users\thoma
User Dir.: C:\Users\thoma\AppData\Local\MapTool\1.17.1
==== Network Interfaces ====
Display Name..: Realtek PCIe GbE Family Controller #2-WFP Native MAC Layer LightWeight Filter-0000
Interface Name: ethernet_0
Display Name..: Realtek PCIe GbE Family Controller #2-QoS Packet Scheduler-0000
Interface Name: ethernet_1
Display Name..: Realtek PCIe GbE Family Controller #2-WFP 802.3 MAC Layer LightWeight Filter-0000
Interface Name: ethernet_2
Display Name..: WAN Miniport (IP)-WFP Native MAC Layer LightWeight Filter-0000
Interface Name: ethernet_3
Display Name..: WAN Miniport (IP)-QoS Packet Scheduler-0000
Interface Name: ethernet_4
Display Name..: WAN Miniport (IPv6)-WFP Native MAC Layer LightWeight Filter-0000
Interface Name: ethernet_5
Display Name..: WAN Miniport (IPv6)-QoS Packet Scheduler-0000
Interface Name: ethernet_6
Display Name..: WAN Miniport (Network Monitor)-WFP Native MAC Layer LightWeight Filter-0000
Interface Name: ethernet_7
Display Name..: WAN Miniport (Network Monitor)-QoS Packet Scheduler-0000
Interface Name: ethernet_8
Display Name..: WAN Miniport (IP)
Interface Name: ethernet_32770
Display Name..: WAN Miniport (IPv6)
Interface Name: ethernet_32771
[lib_Rest.zip](https://github.com/user-attachments/files/22367719/lib_Rest.zip)
Display Name..: WAN Miniport (Network Monitor)
Interface Name: ethernet_32772
Display Name..: Realtek PCIe GbE Family Controller #2
Interface Name: ethernet_32773
Address...: fe80:0:0:0:cbd7:9cd9:12f6:a500%ethernet_32773
Address...: 192.168.0.41
Display Name..: Software Loopback Interface 1
Interface Name: loopback_0
Address...: 0:0:0:0:0:0:0:1
Address...: 127.0.0.1
Host Address...: 192.168.0.41
Default Gateway: 192.168.0.1
==== Locale Information ====
Country.: United States
Language: English
Locale..: English (United States)
Variant.:
==== Encoding Information ====
Default Locale: en_US
Default Charset: UTF-8
file.encoding: UTF-8
sun.jnu.encoding: Cp1252
Default Encoding: UTF8
==== Display Information ====
Number of Displays: 2
Display 1: 1920x1080(32)
Display 2: 1920x1080(32)
==== Internet Gateway Devices ====
No IGDs Found!