Hi everyone,
Could you please help me with the following error?
I try to post with the below code :
B4X:
Sub Button1_Click
Submit_Action
End Sub
Sub Submit_Action
Dim j As HttpJob
j.Initialize("",Me )
j.PostString("http://localhost:4444/SellPLUWithSpecifiedVat(NamePLU=Article1,OptionVATClass=A,Price=10.2,Quantity=1, DiscAddP = 0, DiscAddV = 0)","")
'j.GetRequest.SetContentType("application/json")
Wait For(j) JobDone(j As HttpJob)
If j.Success Then
Log(j.GetString)
End If
j.Release
End Sub
this is the error that i get (from browser the link works fine):
Program started.
<Res Code="63">
<Err Source="Server" Type="ClientInvalidPostFormat">
<Message>Root element is missing.
Content of post body must be valid xml. </Message>
</Err>
</Res>
i don't think that solution is with GET. i should generare a link exactly the same that i sent previously an post.
In the below image you can see what happen from browser.
Below a short description from documentation.
Development/Testing without using auto-generated library
If a library for specific language is not provided, fiscal device operations can be performed by sending HTTP GET request to ZFPLabServer. The server might be running locally or remotely.
API docs and test environment can be found at the following url location: http://localhost:4444
The end user software sends commands in the format: http://ip:4444/command
Examples:
Dim command As String = "SellPLUWithSpecifiedVat(NamePLU=Article1,OptionVATClass=A,Price=10.2,Quantity=1, DiscAddP = 0, DiscAddV = 0)"
Dim su As StringUtils
command = su.EncodeUrl(command, "UTF-8")
Dim j As HttpJob
j.Initialize("",Me )
j.Download("http://localhost:4444/" & command)
Wait For(j) JobDone(j As HttpJob)
If j.Success Then
Log(j.GetString)
End If
j.Release
<Res Code="63">
<Err Source="Server" Type="ClientInvalidPostFormat">
<Message>Root element is missing.
Content of post body must be valid xml. </Message>
</Err>
</Res>
Dim command As String = "SellPLUWithSpecifiedVat(NamePLU=Article1,OptionVATClass=A,Price=10.2,Quantity=1, DiscAddP = 0, DiscAddV = 0)"
Dim su As StringUtils
command = su.EncodeUrl(command, "UTF-8")
Dim j As HttpJob
j.Initialize("",Me )
j.Download("http://localhost:4444/" & command)
Wait For(j) JobDone(j As HttpJob)
If j.Success Then
Log(j.GetString)
End If
j.Release
Sorry ,
Here is the error :
WARNING: package com.sun.javafx.embed.swing.oldimpl not in javafx.swing
Waiting for debugger to connect...
Program started.
<Res Code="11">
<Err Source="Server" Type="ServArgDefMissing">
<Message>attribute name +DiscAddP+ not found in server definitions</Message>
</Err>
</Res>