Get string from respone
I have this REST API that sends the response as text. It would've been easier if the response is JSON or XML but I'm unable to figure out how to play around with response that comes as text.
Case: Response contains 'ConversationID=12345' multiple times since the whole response is coming as text. However, value for 'ConversationID' is same everywhere in the response.
I would like to get the value of ConversationID in the first occurrence using groovy script. I'm not sticking just with groovy. Any other possible way to achieve is fine for me.
Sample Response:
<data contentType="text/plain" contentLength="997"><![CDATA[$REC_TYPE=SYS
ProtocolVersion=7
Status=OK
Message=OK
SetID=
IsLast=Y
StartIndex=0
LastIndex=3
EstimatedTotal=4
ServerTime=2017/09/07 19:49:15 GMT
EOR
$REC_TYPE=TEXTCONVERSATION
ID=5274
CreatorUserID=724
InTime=2017/09/07 19:49:15 GMT
Updated=2017/09/07 19:49:15 GMT
GenericSubject=N
Subject=Test
TotalParticipants=2
Terminated=N
MassConversation=N
Escalated=N
EscalationFinished=N
ParticipationCondition=0
PatientMrn=
EOR
$REC_TYPE=TEXTCONVERSATIONPARTICIPANT
ConversationID=5274
UserID=80
FirstName=Dr
MiddleName=
LastName=Smith
EOR
$REC_TYPE=TEXTCONVERSATIONPARTICIPANT
ConversationID=5274
UserID=724
FirstName=306
MiddleName=
LastName=Engage
EOR
$REC_TYPE=TEXTMESSAGE
ID=15585
ConversationID=5274
InTime=2017/09/07 19:49:15 GMT
CurrentServerTime=2017/09/07 19:49:15 GMT
CreatorMessageID=12351
CreatorUserID=xxx
CreatorFirstName=xxxx
CreatorMiddleName=
CreatorLastName=xxxxx
Severity=1
Body=TestBody
MCR=Y
VoiceCallbackMethod=
Response.0.6657=Yes
Response.1.6658=No
Response.2.6659=Whatever
EOR
]]></data>