cancel
Showing results for 
Search instead for 
Did you mean: 

Working with oData.. where is the edge?

Former Member
0 Kudos

Dear all,

I'm trying to use oData in order to upload interaction contacts into Hybris.

The purpose of my research is to connect directly a custom CRM (not SAP) to Hybris.

I followed the guide Data upload interface 1602 and a manual I received from an Hybris expert.

In the following, the instructions I received:

STEP 1:

Using of "Advanced rest client" and making an OData meta data call to test if the connection to the hybris Marketing system and the authentication is working and fetch token

a. Enter the URL for the meta data call

b. https://<host>:<port>/sap/opu/odata/sap/CUAN_IMPORT_SRV/$metadata

c. Select the checkbox ‘GET’

d. Click on ‘Add new header’ and type in ‘Authorization’. Click on ‘Construct’ and enter your user and password of your hybris Marketing system. The authentication credentials will be encrypted automatically (see e for credentials)

e. User:               …Password:       …

Click on ‘Add new header’ and type in ‘X-CSRF-Token’. Enter ‘Fetch’ as value

STEP 2

Posting data with an OData call

a. After the CSRF token is response from hybris Marketing the post can be done with the rest client to send data in JSON format

b. Enter the URL for the post data call (see c)

c. https:// <host>:<port>/sap/opu/odata/sap/CUAN_IMPORT_SRV/ImportHeaders

d. Select the checkbox ‘POST’

e. Enter the CSRF token you requested in first chapter

f. Setting the content-type to ‘application/json’

a. Enter your JSON

b. After you entered all information your OData post call should look similar to the subsequent screenshot

c. When executing the post data call with ‘Send’ the system executes calls the Inbound API of hybris Marketing to create/update data

I use "Postman" as a Chrome Extension instead of Advanced rest client.

I achieved to upload a contact via Json file and a post method using the URL :

https:// <host>:<port>/sap/opu/odata/sap/CUAN_IMPORT_SRV/ImportHeaders

as suggested.

Anyway I was wondering if it exists something more automatic.. is this the RIGHT way of using oData?

It seems that I need a Json flat file with a list of contacts and then I have to upload the contacts MANUALLY with a post method. Which are the improvements?

In this way I should have a file created by the CRM..

Thanks,

Cristina

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello Cristina,

I think what you describe can be automated with a script.


I work on a Rails application, which uses JBuilder to construct the JSON format expected by the Odata service (of a partner's hybris system, in our case - we do not have an installation ourselves). Then I use the HTTParty gem, to POST the JSON with some headers:


post = HTTParty.post(url, {

  body: send_json,
  verify: false,
  headers: { 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'X-Requested-With' => 'X'  }

  })

(Any other HTTP-gem, or Ruby's Net::HTTP would probably also do though.)

The last header might be responsible for not needing to do what you describe with the CSRF token. (http://stackoverflow.com/questions/17478731/whats-the-point-of-the-x-requested-with-header)

Cheers,

Johann