Forum Discussion

ruhirm's avatar
ruhirm
Occasional Contributor
9 months ago

Re: ReadyAPI as a client of server sent events

Hi all,
I second richie's thought. 
I am stuck at SSE with ReadyAPI. It has been 4 years and still we do not have support on this. I wrote to them and they sent me this same post that I had read before, reaching out to them.

Could somebody who has walked the path share the groovy script for others?

Thanks!
Ruhi

  • Have you tried adding either of below if it is REST or HTTP SSE service which you wanted to listen to?

    • REST Request test step
    • HTTP Request test step

    Once you add the desired step,and run it. In the raw tab, you would see the response (data) from server.

    If you need that response and process it further, no need to use any third party java libraries like this thread says , just do below:

    • add a groovy script test step

    log.info context.response

    One would see the log with response.

    You will have a hold of data which you need and act further as needed.

    For example:

    Data from the server / raw tab shows:

    Below code would filter the lines which has data and just get values say Message1, Message 2 etc

    def lines = context.response.split('\n')
    lines.findAll{it.contains('data')}.each {log.info it.replace('data:','')}

  • nmrao's avatar
    nmrao
    Champion Level 3

    ruhirm 

    May be you should create new question instead of posting new question in the closed post.

    • nmrao's avatar
      nmrao
      Champion Level 3

      I have moved it to new question thought it is not changing the title

  • nmrao's avatar
    nmrao
    Champion Level 3

    Have you tried adding either of below if it is REST or HTTP SSE service which you wanted to listen to?

    • REST Request test step
    • HTTP Request test step

    Once you add the desired step,and run it. In the raw tab, you would see the response (data) from server.

    If you need that response and process it further, no need to use any third party java libraries like this thread says , just do below:

    • add a groovy script test step

    log.info context.response

    One would see the log with response.

    You will have a hold of data which you need and act further as needed.

    For example:

    Data from the server / raw tab shows:

    Below code would filter the lines which has data and just get values say Message1, Message 2 etc

    def lines = context.response.split('\n')
    lines.findAll{it.contains('data')}.each {log.info it.replace('data:','')}

    • nmrao's avatar
      nmrao
      Champion Level 3

      ruhirm have you got chance to look at the above solution and tried?