on 2024 Jan 02 9:42 AM
hi, I'm calling an odata service with patch method.
API_PRODUCTION_ORDER_2_SRV
resource path: A_ProductionOrder_2('ManufacturingOrder')
if I use the Odata adapter I get the error "Bad Request : 400 : HTTP/1.1"
while if I use the http adapter I receive the error: "Name or service not known"
can you help me to call a service with patch method?
thank you
Request clarification before answering.
Please read my blog on this
I hope it will help you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi, I read your blog, I inserted the content modifier immediately after the get call:
but if I look in the trace, I don't have an "if-match" field in the header:
also, when I call the patch method, if I set the resource path in the format you showed in the blog, so: A_ProductionOrder_2(ManufacturingOrder=’${property.ManufacturingOrder}’) I get the following error "Invalid URI syntax.":
Following payload is working fine for me
<?xml version="1.0" encoding="UTF-8"?> <A_ProductionOrder_2><A_ProductionOrder_2Type><TotalQuantity>2.000</TotalQuantity></A_ProductionOrder_2Type></A_ProductionOrder_2>
Remember one point, dont send the same quantity again what you are getting in get call
quantity value should be diffrent from current value
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks, this solved my problem, I accepted you as the correct answer 🙂 thank you very much.
I opened another question regarding a problem on oData, here is the link:
https://answers.sap.com/questions/14030205/format-field-opschedldstarttime-of-odata-api-produ.html
You can not update each field, so send only field which you want to update
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
1. Don't pass ManufacturingOrder field in payload
2. Set property ProductionOrder with the order number you want to update
and in update OData adapter
3.put A_ProductionOrder_2(ManufacturingOrder='${property.ProductionOrder}') in resource path
4. leave the Fields blank
Now it will surely work
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
this is the payload I get from the odata read(get) call (I no longer modify this payload and therefore I also use it for the patch call):
<A_ProductionOrder_2>
<A_ProductionOrder_2Type>
<MfgOrderScheduledStartDate>2020-09-09T00:00:00.000</MfgOrderScheduledStartDate>
<OrderSequenceNumber>0</OrderSequenceNumber>
<ProductConfiguration>0</ProductConfiguration>
<MfgOrderPlannedEndDate>2020-09-15T00:00:00.000</MfgOrderPlannedEndDate>
<MfgOrderCreationTime>1970-01-01T12:20:39.000</MfgOrderCreationTime>
<BasicSchedulingType>4</BasicSchedulingType>
<ManufacturingOrderCategory>10</ManufacturingOrderCategory>
<PlannedOrder></PlannedOrder>
<WBSElementExternalID></WBSElementExternalID>
<OrderIsMarkedForDeletion></OrderIsMarkedForDeletion>
<MfgOrderCreationDate>2020-09-07T00:00:00.000</MfgOrderCreationDate>
<ManufacturingOrderImportance>9</ManufacturingOrderImportance>
<OrderIsPreCosted>X</OrderIsPreCosted>
<OrderIsReleased></OrderIsReleased>
<InventoryUsabilityCode></InventoryUsabilityCode>
<SettlementRuleIsCreated>X</SettlementRuleIsCreated>
<FunctionalArea></FunctionalArea>
<GoodsRecipientName></GoodsRecipientName>
<OrderIsCreated></OrderIsCreated>
<SalesOrder></SalesOrder>
<ManufacturingObject>OR000000613333</ManufacturingObject>
<OrderLongText></OrderLongText>
<BusinessArea></BusinessArea>
<OrderIsConfirmed>X</OrderIsConfirmed>
<UnloadingPointName></UnloadingPointName>
<MfgOrderScheduledStartTime>1970-01-01T08:30:00.000</MfgOrderScheduledStartTime>
<MfgOrderPlannedEndTime>1970-01-01T00:00:00.000</MfgOrderPlannedEndTime>
<OrderIsScheduled></OrderIsScheduled>
<OrderIsDelivered>X</OrderIsDelivered>
<MaterialAvailyIsNotChecked></MaterialAvailyIsNotChecked>
<SettlementRuleIsCrtedManually></SettlementRuleIsCrtedManually>
<OrderHasGeneratedOperations></OrderHasGeneratedOperations>
<PlannedCostsCostingVariant>PPP1</PlannedCostsCostingVariant>
<SalesOrderItem>0</SalesOrderItem>
<MfgOrderScheduledEndDate>2020-09-10T00:00:00.000</MfgOrderScheduledEndDate>
<MfgOrderPlannedStartDate>2020-09-07T00:00:00.000</MfgOrderPlannedStartDate>
<ManufacturingOrderType>PP01</ManufacturingOrderType>
<MaterialGoodsReceiptDuration>0</MaterialGoodsReceiptDuration>
<OrderIsPrinted></OrderIsPrinted>
<MRPArea></MRPArea>
<ProductionUnitSAPCode>N.</ProductionUnitSAPCode>
<MfgOrderActualReleaseDate>2020-09-07T00:00:00.000</MfgOrderActualReleaseDate>
<QuantityDistributionKey></QuantityDistributionKey>
<OrderIsPartiallyReleased></OrderIsPartiallyReleased>
<Plant>BB01</Plant>
<OrderIsLocked></OrderIsLocked>
<TotalQuantity>4</TotalQuantity>
<OrderIsTechnicallyCompleted>X</OrderIsTechnicallyCompleted>
<CustomerName></CustomerName>
<StorageLocation>PR</StorageLocation>
<MfgOrderScheduledEndTime>1970-01-01T09:28:53.000</MfgOrderScheduledEndTime>
<StockSegment></StockSegment>
<ProductionUnit>N.</ProductionUnit>
<MRPController>005</MRPController>
<ProductionSupervisor>000</ProductionSupervisor>
<ProductionPlant>BB01</ProductionPlant>
<ProfitCenter></ProfitCenter>
<ActualCostsCostingVariant>PPP2</ActualCostsCostingVariant>
<OrderIsPartiallyConfirmed></OrderIsPartiallyConfirmed>
<OrderIsDeleted></OrderIsDeleted>
<Material>RATBB010</Material>
<MfgOrderPlannedScrapQty>0</MfgOrderPlannedScrapQty>
<OrderIsPartiallyDelivered></OrderIsPartiallyDelivered>
<OrderInternalBillOfOperations>214574</OrderInternalBillOfOperations>
<OrderIsClosed></OrderIsClosed>
<OrderIsToBeHandledInBatches></OrderIsToBeHandledInBatches>
<MfgOrderConfirmedYieldQty>4</MfgOrderConfirmedYieldQty>
<MfgOrderPlannedStartTime>1970-01-01T00:00:00.000</MfgOrderPlannedStartTime>
<LastChangeDateTime>20210117160101</LastChangeDateTime>
<ProductionUnitISOCode>PCE</ProductionUnitISOCode>
<CompanyCode>BB</CompanyCode>
<ManufacturingOrder>613333</ManufacturingOrder>
<ProductionVersion></ProductionVersion>
</A_ProductionOrder_2Type>
</A_ProductionOrder_2>
etag value will be assigned to if-match, please use read(get) not query(get) operation in first get call, if etag header is not coming
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks, now I get etag.
however the call still fails "com.sap.gateway.core.ip.component.odata.exception.OsciException: Bad Request : 400 : HTTP/1.1"
do I also need to pass the X-CSRF-Token parameter? How can I recover it?
This is the API: API_PRODUCTION_ORDER_2_SRV
resource path: A_ProductionOrder_2('ManufacturingOrder')
method: Patch
403 appears because you have no access to that resource with your credentials.
When you are in Cloud Connector you must use On-Premise to reach your S4h.
the funny think is you are invoking OData with SOAP syntax? You wrote an xml soap body instead json once.
you are confusing 2 different type of format I suppose, on API you must use this body:
{
"d": {
"ManufacturingOrderCategory": "st",
"ManufacturingOrderType": "stri",
"OrderLongText": "string",
"ManufacturingOrderImportance": "s",
"OrderIsCreated": "s",
"OrderIsReleased": "s",
"OrderIsPrinted": "s",
"OrderIsConfirmed": "s",
"OrderIsPartiallyConfirmed": "s",
"OrderIsDelivered": "s",
"OrderIsDeleted": "s",
"OrderIsPreCosted": "s",
"SettlementRuleIsCreated": "s",
"OrderIsPartiallyReleased": "s",
"OrderIsLocked": "s",
"OrderIsTechnicallyCompleted": "s",
"OrderIsClosed": "s",
"OrderIsPartiallyDelivered": "s",
"OrderIsMarkedForDeletion": "s",
"SettlementRuleIsCrtedManually": "s",
"OrderIsScheduled": "s",
"OrderHasGeneratedOperations": "s",
"OrderIsToBeHandledInBatches": "s",
"MaterialAvailyIsNotChecked": "s",
"MfgOrderCreationDate": "/Date(1492041600000)/",
"MfgOrderCreationTime": "PT15H51M04S",
"LastChangeDateTime": "string",
"Material": "string",
"StorageLocation": "stri",
"GoodsRecipientName": "string",
"UnloadingPointName": "string",
"InventoryUsabilityCode": "s",
"MaterialGoodsReceiptDuration": "0",
"QuantityDistributionKey": "stri",
"StockSegment": "string",
"OrderInternalBillOfOperations": "string",
"ProductionPlant": "stri",
"Plant": "stri",
"MRPArea": "string",
"MRPController": "str",
"ProductionSupervisor": "str",
"ProductionVersion": "stri",
"PlannedOrder": "string",
"SalesOrder": "string",
"SalesOrderItem": "string",
"BasicSchedulingType": "s",
"ManufacturingObject": "string",
"ProductConfiguration": "string",
"OrderSequenceNumber": "string",
"BusinessArea": "stri",
"CompanyCode": "stri",
"ProfitCenter": "string",
"ActualCostsCostingVariant": "stri",
"PlannedCostsCostingVariant": "stri",
"FunctionalArea": "string",
"MfgOrderPlannedStartDate": "/Date(1492041600000)/",
"MfgOrderPlannedStartTime": "PT15H51M04S",
"MfgOrderPlannedEndDate": "/Date(1492041600000)/",
"MfgOrderPlannedEndTime": "PT15H51M04S",
"MfgOrderScheduledStartDate": "/Date(1492041600000)/",
"MfgOrderScheduledStartTime": "PT15H51M04S",
"MfgOrderScheduledEndDate": "/Date(1492041600000)/",
"MfgOrderScheduledEndTime": "PT15H51M04S",
"MfgOrderActualReleaseDate": "/Date(1492041600000)/",
"ProductionUnit": "str",
"ProductionUnitISOCode": "str",
"ProductionUnitSAPCode": "str",
"TotalQuantity": "0",
"MfgOrderPlannedScrapQty": "0",
"MfgOrderConfirmedYieldQty": "0",
"CustomerName": "string",
"WBSElementExternalID": "string"
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
if you want you can use OData adapter with xml syntax, but SOAP interface is totally another things.
https://api.sap.com/content-type/API/apis/packages
you are confusing 2 different protocol.
you are using API OData version 2, but why you are using body of a SOAP instead?
No sense.
I've checked on : get_A_ProductionOrder_2
to troubleshooting your error I need example of source body and response body from error exception
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
put and exception handler with this groovy script so we can understand the error.
Did you tested patch with same data in Postman/Insomnia or other client before using Integration Suite?
import com.sap.gateway.ip.core.customdev.util.Message;
//reference:
//https://help.sap.com/viewer/368c481cd6954bdfa5d0435479fd4eaf/Cloud/en-US/a443efe1d5d2403fb95ee9def1a672d4.html
def Message processData(Message message) {
def map = message.getProperties();
def ex = map.get("CamelExceptionCaught");
if (ex!=null) {
message.setProperty("getCanonicalName",ex.getClass().getCanonicalName());
// an http adapter throws an instance of org.apache.camel.component.ahc.AhcOperationFailedException
if (ex.getClass().getCanonicalName().equals("org.apache.camel.component.ahc.AhcOperationFailedException")) {
def messageLog = messageLogFactory.getMessageLog(message);
messageLog.addAttachmentAsString("http.ResponseBody", ex.getResponseBody(), "text/plain");
message.setProperty("http.ResponseBody",ex.getResponseBody());
message.setBody(ex.getResponseBody());
message.setProperty("http.StatusCode",ex.getStatusCode());
message.setProperty("http.StatusText",ex.getStatusText());
}
}
return message;
}
and send me the body of error, (remove confidential data if needed)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
could you provide full path and error?
example: https://myXXXXXX-api.s4hana.cloud.sap/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner
I suppose your path is:
https://myXXXXXX-api.s4hana.cloud.sap/sap/opu/odata/sap/API_PRODUCTION_ORDER_2_SRV/A_ProductionOrder_2('your value of ManufacturingOrder not the name of field')
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
54 | |
8 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.