cancel
Showing results for 
Search instead for 
Did you mean: 

Get request Url parameter from SAP Hybris REST <->CPI <-> ECC (RFC) synchronous in SAP CPI

monikandan_p
Active Participant
0 Kudos

Dear Experts,

Have a requirement to send URL parameter (https://url.com?invoiceNumber=1760101000) from SAP hybris in REST as Get Request to SAP CPI and then pass only the invoiceNumber "1760101000" as request to RFC and the Response will be Binary code in one field and send back the response to SAP Hybris in REST to get invoice as pdf.

Note: Invoice number "1760101000" will be dynamic for every time

Technical Flow:

SAP Hybris (REST) <-> CPI <-> SAP ECC (RFC) (Synchronous)


Please guide me with the steps or any documents if possible.

Much appreciated!

Thanks a lot.

Best Regards,

Moni

View Entire Topic
bhalchandraswcg
Contributor

Hi Moni,

As documented under HTTP Sender Adapter, Header CamelHttpQuery stores all the query parameters.

This Mapping script can be used to fetch the value of a given Query Parameter:

import com.sap.it.api.mapping.MappingContext
import java.net.URLDecoder
import java.nio.charset.StandardCharsets


def String fetchQueryParameter(String queryParameter, MappingContext context) {


	def queryParams = context.getHeader('CamelHttpQuery')?.split('&')


	def queryParamsMap = queryParams.collectEntries { param ->
		param.split('=').collect {
			URLDecoder.decode(it, StandardCharsets.UTF_8.name())
		}
	}


	return queryParamsMap[queryParameter]
}

Hope this helps,

Bala