How to send Json data to api ?

Clovertech Forums Cloverleaf How to send Json data to api ?

  • Creator
    Topic
  • #120121
    Mayank Vaishnavi
    Participant

      Hi there,

      I am new to the cloverleaf. Can someone please share the example on how to send(PUT) the JSON data to the API ?

      In my scenario, HL7 message will be coming at the inbound thread and we need to send the JSON data to the API. I have created the JSON using the JSON configurator and using the Xlate, I have populated the data in the JSON attributes. Now I need to send(PUT) the JSON data to the API.

      Please suggest which  protocol to use and what configuration should be there to make the request and how to handle the response with example?

       

    Viewing 3 reply threads
    • Author
      Replies
      • #120123
        Robert Kersemakers
        Participant

          Hi Mayank,

          You have 2 ways to accomplish this.

          1) http-client
          Pretty straight forward: fill URL, Headers and Method.
          Driver Control Procedures need to be defined as well. If method is PUT or POST, then Driver Mode is ‘Message Driven’; wth a GET you will mostly do this ‘Time Driven’. You have to define a Query TPS; this used to be httpquery with parameters {MSGUSE DATA}. Not sure what the standard script is, but you need this or else it will not work.

          2) java/ws-rawclient
          Next to the standard Bus you will need to create a RawConsumer. Here you can enter your URL, Headers and Method. Create a Conduit if you need TLS, authentication or proxy.

          Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

        • #120125
          Mayank Vaishnavi
          Participant

            Thanks a lot Robert for the response.

            It seems that option 2 will be good in my case i.e., “java/ws-rawclient”

            Is there any way to handle response after hitting(GET/POST) to url and how we can handle the error, if we are not able to reach to url ?

             

             

          • #120131
            Robert Kersemakers
            Participant

              You can handle the response in the Outbound pane of the connection, in ‘Inbound Replies’ with an ‘Await Replies’. Here you can decide whether the response was valid and the message was delivered correctly, or the response was invalid and you need to resend the message.
              Next to this you can also route the reply/response to another thread to send it on/back to another system.

              I have seen that there is an error whenever you can;t reach the URL, but haven’t figured out how to prevent this. However when setting a timeout on the ‘Wait Replies’ and resending the message when no response came in (because there was no message delivered). Need to have a closer look at that, if I have some spare time.

               

              Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

            • #120142
              Mayank Vaishnavi
              Participant

                Thanks a lot for the help.

            Viewing 3 reply threads
            • You must be logged in to reply to this topic.