Reputation: 1
I was curious to know if we can call a Post api using the response of a Get api in CRM. I was trying to achieve this using groovy script. I have registered both the Get and Post api in CRM. Is it possible? Calling the post using the field values in the Get api response?
Could the mapping of Get api response and Post api Request be done in groovy itself without saving the response?
Right now I'm able to do Get and Post separately
Get(Get_Journal) API Script:
def PONumber = PONumber_c //Picking parameter from a field names PONumber
def x = adf.webServices.Get_Journal.GET(PONumber)
setAttribute('EquipmentDescription_c',x.JeBatchId) // Extract values
setAttribute('BranchLocation_c',x.AccountedPeriodType) //Populating response
Post(Create_Resvtn_test) API Script:
def opty = adf.webServices.Create_Resvtn_test
try{
def RecordName =[RecordName:'NewReservation'] //Request Payload
def httpHeaders=['Content-Type':'application/json']
opty.requestHTTPHeaders=httpHeaders
def newOpty = opty.POST(RecordName)
}catch(Exception e){
println("Headers:"+opty.RecordName)
println("-----------------------------------------------------")
println("Status:"+opty.statusCode)
println("-----------------------------------------------------")
println("Error:"+e)
println("-----------------------------------------------------")
}
Can it be combined together using just one script?
Upvotes: 0
Views: 28