11-30-2022 2:46 PM - edited 02-04-2024 4:54 AM
Hi everyone.
I try to change the Business Partner standard address using API API_BUSINESS_PARTNER.
If I try to just delete the standard usage i get an error.
Then i found a Note: https://launchpad.support.sap.com/#/notes/3108581/D
In there it says, that I need to do a Batch-Request. Unfortunately this doesn't work for me.
I try the following:
--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary
DELETE A_BuPaAddressUsage(BusinessPartner='9980000021',ValidityEndDate=datetimeoffset'9999-12-31T23%3A59%3A59Z',AddressUsage='XXDEFAULT',AddressID='159') HTTP/1.1
POST A_BuPaAddressUsage
Content-Type: application/json
{
{
"BusinessPartner": "9980000021",
"ValidityEndDate": "/Date(253402297199000)/",
"AddressUsage": "XXDEFAULT",
"AddressID": "103632",
"ValidityStartDate": "/Date(1669804880800)/",
"StandardUsage": true
}
}
--changeset--<br>
I get the this Error:
"The Data Services Request could not be understood due to malformed syntax"
If I try the Batch with a GET it works:
--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary
GET A_BuPaAddressUsage(BusinessPartner='9980000021',ValidityEndDate=datetimeoffset'9999-12-31T23%3A59%3A59Z',AddressUsage='XXDEFAULT',AddressID='159') HTTP/1.1
--changeset--<br>
Has anyone an idea what the problem could be?
Thanks in advance
Robin
Hi Robin
You need to separate the 2 operations into changesets. Here is an example:
Request:
/sap/opu/odata/sap/API_BUSINESS_PARTNER/$batch
Header parameter:
Content-Type multipart/mixed; boundary=batch
Payload:
--batch
Content-Type: multipart/mixed; boundary=changeset
--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary
DELETE A_BuPaAddressUsage(BusinessPartner='1010111111',ValidityEndDate=datetimeoffset'9999-12-31T23%3A59%3A59Z',AddressUsage='XXDEFAULT',AddressID='XXXXXX') HTTP/1.1
Content-Type: application/json
--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary
POST A_BuPaAddressUsage HTTP/1.1
Content-Type: application/json
{
"BusinessPartner": "1010004614",
"ValidityEndDate": "2022-11-30T00:00:00Z",
"AddressUsage": "XXDEFAULT",
"AddressID": "XXXXXX"
}
--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary
POST A_BusinessPartner('1010111111')/to_BusinessPartnerAddress HTTP/1.1
Content-Type: application/json
{
"Country": "US",
"Language": "EN",
"HouseNumber": "",
"HouseNumberSupplementText": "",
"POBox": "",
"POBoxPostalCode": "",
"PostalCode": "",
"PrfrdCommMediumType": "INT",
"to_AddressUsage": [{
"AddressUsage": "XXDEFAULT"
}]
}
--changeset--
--batch--
Thanks,
Marty
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Marty.
Thank you for your answer. Unfortunately I still get an error.
Header:
multipart/mixed; boundary=batch
Payload:
--batch
Content-Type: multipart/mixed; boundary=changeset
--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary
DELETE A_BuPaAddressUsage(BusinessPartner='9980000021',ValidityEndDate=datetimeoffset'9999-12-31T23%3A59%3A59Z',AddressUsage='XXDEFAULT',AddressID='159') HTTP/1.1
Content-Type: application/json
--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary
POST A_BuPaAddressUsage HTTP/1.1
Content-Type: application/json
{
"BusinessPartner": "9980000021",
"ValidityEndDate": "9999-12-31T23:59:59Z",
"AddressUsage": "XXDEFAULT",
"AddressID": "103632"
}
--changeset--
--batch--
Error: Batch request payload is invalid
Thank you again for your assistance.
-Robin
Hi Marty
I am working with Robin on this. I tried your solution and it says, that there are no operations. Am I missing something? I split it into 2 changesets.
I set the Content-Type header to "multipart/mixed;boundary=batch"
My payload would be the following (followed by the response):
-batch
Content-Type: multipart/mixed; boundary=changeset
--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary
DELETE A_BuPaAddressUsage(BusinessPartner='9980000021',ValidityEndDate=datetimeoffset'9999-12-31T23:59:59Z',AddressUsage='XXDEFAULT',AddressID='159') HTTP/1.1
--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary
POST A_BusinessPartnerAddress(BusinessPartner='1026455',AddressID='103562')/to_AddressUsage HTTP/1.1
Content-Type: application/json
{
"ValidityEndDate": "/Date(1669823222416)/",
"AddressUsage": "XXDEFAULT",
"StandardUsage": true
}
--changeset--
--batch--
<?xml version="1.0" encoding="utf-8"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code>00505692409C1EEA80C6EC2C0FB69918</code>
<message xml:lang="en">Batch request payload does not contain any operations</message>
<innererror xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<transactionid>0CEB09232DE701B0E006387046F28A54</transactionid>
<timestamp>20221130163144.7046680</timestamp>
<Error_Resolution>
<SAP_Transaction>For backend administrators: use ADT feed reader "SAP Gateway Error Log" or run transaction /IWFND/ERROR_LOG on SAP Gateway hub system and search for entries with the timestamp above for more details</SAP_Transaction>
<SAP_Note>See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)</SAP_Note>
</Error_Resolution>
</innererror>
</error>
*EDIT*
First batch was missing a hyphen.
Hi Marty
I managed to get some responses but the DELETE operation seems to get ignored for some reason. I get responses for the 2 POST requests but not de DELETE.
-batch
Content-Type: multipart/mixed; boundary=changeset
--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary
DELETE A_BuPaAddressUsage(BusinessPartner='9980000021',ValidityEndDate=datetimeoffset'9999-12-31T23:59:59Z',AddressUsage='XXDEFAULT',AddressID='159') HTTP/1.1
--changeset--
--batch
Content-Type: multipart/mixed; boundary=changeset
--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary
POST A_BusinessPartnerAddress(BusinessPartner='9980000021',AddressID='159')/to_AddressUsage HTTP/1.1
Content-Type: application/json
{
"ValidityEndDate": "/Date(1669849199000)/",
"AddressUsage": "XXDEFAULT",
"StandardUsage": false
}
--changeset--
--batch
Content-Type: multipart/mixed; boundary=changeset
--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary
POST A_BusinessPartnerAddress(BusinessPartner='9980000021',AddressID='103632')/to_AddressUsage HTTP/1.1
Content-Type: application/json
{
"ValidityStartDate": "/Date(1669849199000)/",
"ValidityEndDate": "/Date(253402297199000)/",
"AddressUsage": "XXDEFAULT",
"StandardUsage": true
}
--changeset--
--batch--
Hi Gregor
I havent seen this error before, can you confirm URL is /sap/opu/odata/sap/API_BUSINESS_PARTNER/$batch?
Also, the opening batch in your payload is missing a hyphen, is that a copy/paste error or is it missing? Are you using Postman? You have body type set to raw?
Marty
*EDIT*
I checked and there was actually a hyphen missing. Now I get all 3 responses. Thank you very much.
Hi Marty
Yes, that's the API I'm using.
I sort of resolved the issue by not only adding multiple changesets but also a batch for each changeset. But now only 2 out of 3 Requests seem to be processed. (referring to my 2nd reply)
Hi Marty
Now that this seems to work. What is the difference between using 1 batch with multiple changesets and using 1 batch for every changeset (batch 1:n changesets vs batch 1:1 changeset)?
According to the response with the first case, the requests are handled one by one. The latter case gives a response of all the requests at once, though I don't know if they are sync or async.
User | Count |
---|---|
96 | |
7 | |
6 | |
6 | |
3 | |
3 | |
3 | |
2 | |
2 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.