Skip to main content
New Participant
Jun 14, 2024 5:44 PM UTC
Solved

submitrequest

New to this so please bear with me...

I am trying to use 'submitrequest' for the first time to pull contact from a URL. Below is what I have thus far but it doesn't appear to be working. Does anyone have experience doing this?

If I manually use the URL in a browser, it works. When i try in a program, it doesn't.

001: URL = "https://trison-dev.myxcarrier.com/ECSAPI/Labels/275926435770.txt"
002: HTTP.STATUS=''
003: TIME.OUT='3000'
004: RESP.DATA=""
005: RESP.HEADER = ""
006:
007: RESP = createRequest(URL,'GET',HTTP.HANDLER)
008: CRT "Reponse to create request = ":RESP
009: RESP = submitRequest(HTTP.HANDLER,TIME.OUT,'',RESP.HEADER,RESP.DATA,HTTP.STATUS)
010: CRT RESP
011: CRT "HTTP.STATUS - ":HTTP.STATUS

I ran the test and received the following:

:TEST.HTTPS
Reponse to create request = 0
0
HTTP.STATUS - 400ýBad Request

    John Jenkins
    Participating Frequently
    Jun 16, 2024 12:53 PM UTC

    New to this so please bear with me...

    I am trying to use 'submitrequest' for the first time to pull contact from a URL. Below is what I have thus far but it doesn't appear to be working. Does anyone have experience doing this?

    If I manually use the URL in a browser, it works. When i try in a program, it doesn't.

    001: URL = "https://trison-dev.myxcarrier.com/ECSAPI/Labels/275926435770.txt"
    002: HTTP.STATUS=''
    003: TIME.OUT='3000'
    004: RESP.DATA=""
    005: RESP.HEADER = ""
    006:
    007: RESP = createRequest(URL,'GET',HTTP.HANDLER)
    008: CRT "Reponse to create request = ":RESP
    009: RESP = submitRequest(HTTP.HANDLER,TIME.OUT,'',RESP.HEADER,RESP.DATA,HTTP.STATUS)
    010: CRT RESP
    011: CRT "HTTP.STATUS - ":HTTP.STATUS

    I ran the test and received the following:

    :TEST.HTTPS
    Reponse to create request = 0
    0
    HTTP.STATUS - 400ýBad Request

    Daniel,

    David has the hit the nail on the head for the issue - this is a secure site, There are examples in he Knowledge around handling secure requests - e.g.

    https://my.rocketsoftware.com/RocketCommunity/s/article/How-to-get-the-geo-latitude-and-longitude-information-based-on-the-provided-address-using-Google-Map-APIs

    Regards

    JJ

    JJ

    5 replies

    David Green
    Inspiring
    Jun 15, 2024 5:31 PM UTC

    New to this so please bear with me...

    I am trying to use 'submitrequest' for the first time to pull contact from a URL. Below is what I have thus far but it doesn't appear to be working. Does anyone have experience doing this?

    If I manually use the URL in a browser, it works. When i try in a program, it doesn't.

    001: URL = "https://trison-dev.myxcarrier.com/ECSAPI/Labels/275926435770.txt"
    002: HTTP.STATUS=''
    003: TIME.OUT='3000'
    004: RESP.DATA=""
    005: RESP.HEADER = ""
    006:
    007: RESP = createRequest(URL,'GET',HTTP.HANDLER)
    008: CRT "Reponse to create request = ":RESP
    009: RESP = submitRequest(HTTP.HANDLER,TIME.OUT,'',RESP.HEADER,RESP.DATA,HTTP.STATUS)
    010: CRT RESP
    011: CRT "HTTP.STATUS - ":HTTP.STATUS

    I ran the test and received the following:

    :TEST.HTTPS
    Reponse to create request = 0
    0
    HTTP.STATUS - 400ýBad Request

    Since the URL is https shouldn't you be using createSecureRequest?

    John Jenkins
    Participating Frequently
    Jun 16, 2024 12:53 PM UTC

    New to this so please bear with me...

    I am trying to use 'submitrequest' for the first time to pull contact from a URL. Below is what I have thus far but it doesn't appear to be working. Does anyone have experience doing this?

    If I manually use the URL in a browser, it works. When i try in a program, it doesn't.

    001: URL = "https://trison-dev.myxcarrier.com/ECSAPI/Labels/275926435770.txt"
    002: HTTP.STATUS=''
    003: TIME.OUT='3000'
    004: RESP.DATA=""
    005: RESP.HEADER = ""
    006:
    007: RESP = createRequest(URL,'GET',HTTP.HANDLER)
    008: CRT "Reponse to create request = ":RESP
    009: RESP = submitRequest(HTTP.HANDLER,TIME.OUT,'',RESP.HEADER,RESP.DATA,HTTP.STATUS)
    010: CRT RESP
    011: CRT "HTTP.STATUS - ":HTTP.STATUS

    I ran the test and received the following:

    :TEST.HTTPS
    Reponse to create request = 0
    0
    HTTP.STATUS - 400ýBad Request

    Daniel,

    David has the hit the nail on the head for the issue - this is a secure site, There are examples in he Knowledge around handling secure requests - e.g.

    https://my.rocketsoftware.com/RocketCommunity/s/article/How-to-get-the-geo-latitude-and-longitude-information-based-on-the-provided-address-using-Google-Map-APIs

    Regards

    JJ

    JJ
    New Participant
    Jun 17, 2024 12:07 PM UTC

    New to this so please bear with me...

    I am trying to use 'submitrequest' for the first time to pull contact from a URL. Below is what I have thus far but it doesn't appear to be working. Does anyone have experience doing this?

    If I manually use the URL in a browser, it works. When i try in a program, it doesn't.

    001: URL = "https://trison-dev.myxcarrier.com/ECSAPI/Labels/275926435770.txt"
    002: HTTP.STATUS=''
    003: TIME.OUT='3000'
    004: RESP.DATA=""
    005: RESP.HEADER = ""
    006:
    007: RESP = createRequest(URL,'GET',HTTP.HANDLER)
    008: CRT "Reponse to create request = ":RESP
    009: RESP = submitRequest(HTTP.HANDLER,TIME.OUT,'',RESP.HEADER,RESP.DATA,HTTP.STATUS)
    010: CRT RESP
    011: CRT "HTTP.STATUS - ":HTTP.STATUS

    I ran the test and received the following:

    :TEST.HTTPS
    Reponse to create request = 0
    0
    HTTP.STATUS - 400ýBad Request

    John - This was super helpful and worked on my first try.

    Is there also examples of the method = POST? Before I GET, I am having to POST a request and this is what initiates the GET, if the request is successful.

    Again, I am new to using API and the Unidata 'submitRequest' / 'createSecureRequest' , so I appreciate all the help.

    John Jenkins
    Participating Frequently
    Jun 17, 2024 3:07 PM UTC

    New to this so please bear with me...

    I am trying to use 'submitrequest' for the first time to pull contact from a URL. Below is what I have thus far but it doesn't appear to be working. Does anyone have experience doing this?

    If I manually use the URL in a browser, it works. When i try in a program, it doesn't.

    001: URL = "https://trison-dev.myxcarrier.com/ECSAPI/Labels/275926435770.txt"
    002: HTTP.STATUS=''
    003: TIME.OUT='3000'
    004: RESP.DATA=""
    005: RESP.HEADER = ""
    006:
    007: RESP = createRequest(URL,'GET',HTTP.HANDLER)
    008: CRT "Reponse to create request = ":RESP
    009: RESP = submitRequest(HTTP.HANDLER,TIME.OUT,'',RESP.HEADER,RESP.DATA,HTTP.STATUS)
    010: CRT RESP
    011: CRT "HTTP.STATUS - ":HTTP.STATUS

    I ran the test and received the following:

    :TEST.HTTPS
    Reponse to create request = 0
    0
    HTTP.STATUS - 400ýBad Request

    Daniel,

    I think one of the samples provided - possibly in the XDEMO account - uses POST, otherwise there should be a worked example.

    Hopefully this helps.

    also does this help? https://community.rocketsoftware.com/question/how-to-use-post-multipartform-data-to-upload-a-file

    Regards,

    JJ

    JJ
    Brian Leach
    Participating Frequently
    Jun 18, 2024 9:13 AM UTC

    New to this so please bear with me...

    I am trying to use 'submitrequest' for the first time to pull contact from a URL. Below is what I have thus far but it doesn't appear to be working. Does anyone have experience doing this?

    If I manually use the URL in a browser, it works. When i try in a program, it doesn't.

    001: URL = "https://trison-dev.myxcarrier.com/ECSAPI/Labels/275926435770.txt"
    002: HTTP.STATUS=''
    003: TIME.OUT='3000'
    004: RESP.DATA=""
    005: RESP.HEADER = ""
    006:
    007: RESP = createRequest(URL,'GET',HTTP.HANDLER)
    008: CRT "Reponse to create request = ":RESP
    009: RESP = submitRequest(HTTP.HANDLER,TIME.OUT,'',RESP.HEADER,RESP.DATA,HTTP.STATUS)
    010: CRT RESP
    011: CRT "HTTP.STATUS - ":HTTP.STATUS

    I ran the test and received the following:

    :TEST.HTTPS
    Reponse to create request = 0
    0
    HTTP.STATUS - 400ýBad Request

    Also worth pointing out that this can be a good use case for Python if you have that enabled.

    Create a simple method in a Python module something like (just typed in here, so don't take as gospel)

    import http.client

    def postURL(self, host, url, someData):
          conn = http.client.HTTPSConnection(host)
          conn.request('POST',url, someData)
          r = conn.getresponse().read()
          conn.close()
          return str(r)

    then use PyCallFunction() to call it from UniBasic.