简体   繁体   中英

unable to perform Delete operation on Odata services using s4sdk

I followed the blog & I was able to perform create, read & update operations on my custom OData service, but I am unable to find any blog/document for delete operation. Please help.

There is no dedicated blog post for executing delete operations on custom OData Services but we would advise you to follow this pattern:

public class DeleteAddressCommand extends ErpCommand<Integer> {
    private static final Logger logger = CloudLoggerFactory.getLogger(DeleteAddressCommand.class);

    private final BusinessPartnerService service;
    private final String businessPartnerId;
    private final String addressId;

    public DeleteAddressCommand(final BusinessPartnerService service,
                                final String businessPartnerId, final String addressId) {
        super(HystrixUtil.getDefaultErpCommandSetter(
                DeleteAddressCommand.class,
                HystrixUtil.getDefaultErpCommandProperties().withExecutionTimeoutInMilliseconds(10000)));

        this.service = service;
        this.businessPartnerId = businessPartnerId;
        this.addressId = addressId;
    }

    @Override
    protected Integer run() throws Exception {
        final BusinessPartnerAddress addressToDelete = BusinessPartnerAddress.builder()
                .businessPartner(businessPartnerId)
                .addressID(addressId)
                .build();

        final ODataDeleteResult oDataDeleteResult = service
                .deleteBusinessPartnerAddress(addressToDelete)
                .execute();

        return oDataDeleteResult.getHttpStatusCode();
    }
}

I pasted the code from this official example

Best wishes Florian

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM