B4J Question Post Multipart question

walterf25

Expert
Licensed User
Longtime User
Hello all, this is sort of my first time using B4J, i'm trying to write a small program which can send messages to a satellite radio, i have all the documentation regarding their api, the messages are sent to the device and the devices sends them to a core service, according to their documentation i can send a message using the following api link

the xxxx would be the serial number of the device i would want to send the message to.

this is what the documentation describes

$ curl -d "username=xxx&password=yyy&data=8a8c8b" \
"https://core.rock7.com/API2/SendRawMessage/2322"

<?xml version="1.0" encoding="UTF-8"?>
<SendRawMessage><receipt messageId="21199" /></SendRawMessage>

If i go to a service like https://www.hurl.it/ i can send the message just fine, it works perfect, but if i try to do it using the jOKhttputils2 in B4J i get a response that says authentication error.

Can anyone help me figure out what i'm doing wrong?

This is the relevant part of my code.

B4X:
Sub btnsend_MouseClicked (EventData As MouseEvent)
    If txtfrom <> "" Then
        txtmsg = txtfrom & "," & txtmsg
    Else
        Log("email address is empty, plese enter email address")
        Return
    End If
    Dim msgbytes() As Byte
    Dim hexstring As String
    msgbytes = txtmsg.GetBytes("UTF8")
     hexstring = hex.HexFromBytes(msgbytes)
    Log("https://core.rock7.com/API2/SendRawMessage/" & deviceSerialNumber)
    job1.PostMultipart("https://core.rock7.com/API2/SendRawMessage/" & deviceSerialNumber & "/", CreateMap("username": "xxxxxxx", "password": "yyyyy", "data": hexstring),Null)
End Sub

Any suggestions anybody?

Please note i don't get an error while running the program, what i get is the response from the server saying <Error>Authentication failure</Error>

What i don't understand is why it works with the hurl.it service but it won't work when running it on my small program?

Thanks all.

Walter
 

walterf25

Expert
Licensed User
Longtime User
Upvote 0
Top