Skip to Content
2
Sep 05, 2018 at 07:17 PM

CSRF token validation failed - 403 Forbidden calling Hybris API_MKT_CONTACT_SRV with PUT

5343 Views Last edit Sep 05, 2018 at 11:52 PM 2 rev

Hi Folks,

I have a Hybris system 1709 provisioned through CAL. There is no Hybris related data populated. So I am trying to create a contact.

I am using the API_MKT_CONTACT_SRV service.

I am doing a Get with the X-csrf-token=fetch in the Header.

Then I am posting a contact using a PUT using the returned x-csrf-token:

http://myIP:myPort/sap/opu/odata/sap/API_MKT_CONTACT_SRV;v=0002/Contacts

Here is the JSON I am using from How to import Contact Data via OData Services to SAP Hybris Marketing by Johannes Hirling

{
	"batchParts": {
		"batchChangeSet": {
			"batchChangeSetPart": {
				"method": "PUT",
				"ContactOriginData": {
					"ContactOriginData": {
						"LastName": "Test",
						"FirstName": "Tom",
						"EmailAddress": "JHI_001@test.com",
						"Country": "US",
						"ContactPostalCode": "60611",
						"ContactOrigin": "SAP_ERP_CONTACT",
						"ContactID": "JHI_001",
						"CityName": "Chicago",
						"BirthDate": "2000-12-13",
						"OriginDataLastChgUTCDateTime": "0000-00-00T00:00:00"
					}
				}
			}
		}
	}
}

Here I am passing the x-csrf-token

Response header:

Any help would be appreciated.

Thanks,

Jay