B4J Question API Post /Get with result problem

Discussion in 'B4J Questions' started by Peter Lewis, May 20, 2017.

Similar threads

B4J Tutorial SQL Tutorial
B4J Tutorial [B4X] Resumable Subs - Sleep / Wait For
B4J Tutorial Pagination Container
B4J Tutorial Msgbox / InputList
B4J Tutorial Unhandled exceptions
B4J Tutorial Accordion container
  1. Peter Lewis

    Peter Lewis Active Member Licensed User

    HI All

    I have been trying to get a currency update from an API. If I put the string in the browser then I get the correct response. Now I have tried thru code mixing and matching info that I got from B4A and at the moment the requests go thru but no return info

    If you have any input, please let me know. THX

    #Region Project Attributes
    #MainFormWidth: 600
    #MainFormHeight: 600
    #End Region

    Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private Button1 As Button
    End Sub

    Sub AppStart (Form1 As Form, Args() As String)
        MainForm = Form1
    "1"'Load the layout file.
    End Sub

    'Return true to allow the default exceptions handler to handle the uncaught exception.
    Sub Application_Error (Error As Exception, StackTrace As StringAs Boolean
    Return True
    End Sub

    Sub req

    Dim j As HttpJob



    Dim result As ResultSet 'String
        result= j.Poststring(j.Download)

    "Content-Type""application/json; charset=utf-8")

    End Sub

    Sub JobDone (job1 As HttpJob)
    Dim resultJSON As String
    Log("USDZAR " &  job1.JobName)
    Log("jobsucess " & job1.Success )
        resultJSON = job1.GetString
    Log ("JSON " & resultJSON)

    End Sub
  2. Enrique Gonzalez R

    Enrique Gonzalez R Well-Known Member Licensed User

    This is the part giving you problems.

    Dim result As ResultSet 'String
        result= j.Poststring(j.Download)
    just get rid of it, poststring doesnt return a resulset. You have to use the json library to parse the information coming from the url.

    this is the response from the url:

    Waiting for debugger to connect...
    Program started.
    jobsucess true
    JSON {