cancel
Showing results for 
Search instead for 
Did you mean: 

OData Payload - can't PATCH AgreementTerms

mmangels85
Explorer
231

Hello experts,

one of my OData-Payloads is giving me a hard time. I checked the API numerous times, all the mandatory fields are filled and I'm at a loss why I keep getting a 400 - Bad Request. If I remove the 'AgreementTerms' part it works perfectly fine, but I can't get it to work as a whole.

--batch
Content-Type: multipart/mixed; boundary=changeset_1

--changeset_1
Content-Type: application/http
Content-Transfer-Encoding: binary
PATCH Agreements(MKT_AgreementOrigin='CRM',MKT_AgreementExternalID='40001') HTTP/1.1
Content-Type:  application/json
Content-Length: ###
Sap-Cuan-SourceSystemId: XXXCLN123
Sap-Cuan-SourceSystemType:
Sap-Cuan-SequenceId: AGREEMENT_MASTER_DATA
Sap-Cuan-RequestTimestamp: 20170508141617.0000001
Sap-Cuan-ExternalReferenceId: XXXCLN12320170508141617_01

{
"MKT_AgreementOrigin":"CRM",
"MKT_AgreementExternalID":"40001",
"ContactID":"20001",
"ContactOrigin":"MAFIS",
"MKT_AgreementType":"VERTR_STRO",
"MKT_AgreementStartDateTime":"2018-01-01T00:00:00",
"MKT_AgreementEndDateTime":"2019-12-31T00:00:00",
"MKT_MarketingArea":"ENERGIE",
"MKT_AgreementIsCanceled":false,
"MKT_AgrmtCancellationReason":"",
"YY1_CONSUMPTION_VALUE_MKT":"5000",
"YY1_CONSUMPTION_UNIT_MKT":"kWh",
"OriginDataLastChgUTCDateTime":"/Date(1574636400000)/"
}

--changeset_1
Content-Type: application/http
Content-Transfer-Encoding: binary

PATCH AgreementTerms(MKT_AgreementOrigin='CRM',MKT_AgreementExternalID='40001',MKT_AgrmtTermsStartDateTime='2018-01-01T00:00:00',MKT_AgrmtTermsEndDateTime='2019-12-31T00:00:00') HTTP/1.1
Content-Type:  application/json
Content-Length: ###
Sap-Cuan-SourceSystemId: XXXCLN123
Sap-Cuan-SourceSystemType:
Sap-Cuan-SequenceId: AGREEMENT_MASTER_DATA
Sap-Cuan-RequestTimestamp: 20170508141617.0000001
Sap-Cuan-ExternalReferenceId: XXXCLN12320170508141617_01


{
"MKT_AgreementStatus":"A",
"MKT_AgreementRenewalType":"3",
"ProductOrigin":"CRM",
"ProductID":"STROM_PRODUKT_1",
"MKT_AgrmtCanclnConditions":"3",
"MKT_AgreementPaymentFrequency":"4",
"OriginDataLastChgUTCDateTime":"/Date(1574636400000)/"
}

--changeset_1--
 --batch--

I would be very thankfu for any ideas.

Accepted Solutions (0)

Answers (3)

Answers (3)

WolfgangGedemer
Advisor
Advisor

Hi Maximilian,

just add an empty line in front of PATCH:


....
--changeset_1
Content-Type: application/http
Content-Transfer-Encoding: binary

PATCH Agreements(MKT_AgreementOrigin='CRM',MKT_AgreementExternalID='40001') HTTP/1.1
Content-Type:  application/json
Content-Length: ###
....

Best Regards,
Wolfgang

mmangels85
Explorer
0 Kudos

Thank you Wolfgang, but that was just a formatting error by copying it here. The payload looks like this:

--batch
Content-Type: multipart/mixed; boundary=changeset_1


--changeset_1
Content-Type: application/http
Content-Transfer-Encoding: binary




PATCH Agreements(MKT_AgreementOrigin='CRM',MKT_AgreementExternalID='40001') HTTP/1.1
Content-Type:  application/json
Content-Length: ###
Sap-Cuan-SourceSystemId: XXXCLN123
Sap-Cuan-SourceSystemType:
Sap-Cuan-SequenceId: AGREEMENT_MASTER_DATA
Sap-Cuan-RequestTimestamp: 20170508141617.0000001
Sap-Cuan-ExternalReferenceId: XXXCLN12320170508141617_01


{
"MKT_AgreementOrigin":"CRM",
"MKT_AgreementExternalID":"40001",
"ContactID":"20001",
"ContactOrigin":"MAFIS",
"MKT_AgreementType":"VERTR_STRO",
"MKT_AgreementStartDateTime":"2018-01-01T00:00:00",
"MKT_AgreementEndDateTime":"2019-12-31T00:00:00",
"MKT_MarketingArea":"ENERGIE",
"MKT_AgreementIsCanceled":false,
"MKT_AgrmtCancellationReason":"",
"YY1_CONSUMPTION_VALUE_MKT":"5000",
"YY1_CONSUMPTION_UNIT_MKT":"kWh",
"OriginDataLastChgUTCDateTime":"/Date(1574636400000)/"
}




--changeset_1
Content-Type: application/http
Content-Transfer-Encoding: binary




PATCH AgreementTerms(MKT_AgreementOrigin='CRM',MKT_AgreementExternalID='40001',MKT_AgrmtTermsStartDateTime=datetimeoffset'2018-01-01T00:00:01Z',MKT_AgrmtTermsEndDateTime=datetimeoffset'2019-12-31T00:00:01Z') HTTP/1.1
Content-Type:  application/json
Content-Length: ###
Sap-Cuan-SourceSystemId: XXXCLN123
Sap-Cuan-SourceSystemType:
Sap-Cuan-SequenceId: AGREEMENT_MASTER_DATA
Sap-Cuan-RequestTimestamp: 20170508141617.0000001
Sap-Cuan-ExternalReferenceId: XXXCLN12320170508141617_01


{
"MKT_AgreementOrigin":"CRM",
"MKT_AgreementExternalID":"40001",
"MKT_AgrmtTermsStartDateTime":"2018-01-01T00:00:00",
"MKT_AgrmtTermsEndDateTime="2019-12-31T00:00:00",
"MKT_AgreementStatus":"A",
"MKT_AgreementRenewalType":"3",
"ProductOrigin":"CRM",
"ProductID":"STROM_PRODUKT_1",
"MKT_AgrmtCanclnConditions":"3",
"MKT_AgreementPaymentFrequency":"4",
"OriginDataLastChgUTCDateTime":"/Date(1574636400000)/"
}




--changeset_1--


--batch--
SCHNEIDERT
Active Contributor

Hi mmangels85,

for me your request looks good.

Comparing it to the one I found in the integration guide (https://help.sap.com/viewer/0f9408e4921e4ba3bb4a7a1f75f837a7/1911.500/en-US/ef61a9b667c84404bee37775...), the only difference I can see is the format of the timestamp of your AgreementTerms part. In the Payload example there is an addition "datetimeoffset".

I don't know if this could cause your bad request.

Anything else seems fine for me.

BR Tobias

mmangels85
Explorer
0 Kudos

Thank you for your reply Tobias.

I edited my request but unfortunately, it didn't help.

For anyone else coming here looking for advice on the timestamp: the example payload has some butchered punctuation.

It is supposed to read [...]=datetimeoffset'2012-01-01T00:00:00Z'
--batch
Content-Type: multipart/mixed; boundary=changeset_1

--changeset_1
Content-Type: application/http
Content-Transfer-Encoding: binary

PATCH AgreementTerms(MKT_AgreementOrigin='CRM',MKT_AgreementExternalID='40001',MKT_AgrmtTermsStartDateTime=datetimeoffset'2018-01-01T00:00:01+01:00',MKT_AgrmtTermsEndDateTime=datetimeoffset'2019-12-31T00:00:01+01:00') HTTP/1.1
Content-Type:  application/json
Content-Length: ###
Sap-Cuan-SourceSystemId: XXXCLN123
Sap-Cuan-SourceSystemType:
Sap-Cuan-SequenceId: AGREEMENT_MASTER_DATA
Sap-Cuan-RequestTimestamp: 20170508141617.0000001
Sap-Cuan-ExternalReferenceId: XXXCLN12320170508141617_01

{
"MKT_AgreementStatus":"A",
"MKT_AgreementRenewalType":"3",
"ProductOrigin":"CRM",
"ProductID":"STROM_PRODUKT_1",
"MKT_AgrmtCanclnConditions":"3",
"MKT_AgreementPaymentFrequency":"4",
"OriginDataLastChgUTCDateTime":"/Date(1574636400000)/"
}

--changeset_1--
--batch--
WolfgangGedemer
Advisor
Advisor
0 Kudos

Hi Maximilian,

try to use this payload: payloadwithoneemptyline.txt

Only one empty row in front of "PATCH"-row.

Best Regards,
Wolfgang