11-08-2021 8:34 PM - edited 02-04-2024 2:55 AM
Hello guys,
I've been using following API to update Commercial Projects: https://api.sap.com/api/_CPD_SC_PROJ_ENGMT_CREATE_UPD_SRV/resource
I wanted to do "mass update" of ProjectStage which can be done by sending a PATCH.
I've been doing that in my UI5 app but unfortunately I have come to error handling -> to handle the errors I would like to know on which entity the error occurred. I'm sending 100 requests in a deferredGroup but the message of an error is not returning project ID for which the PATCH was requested.
The body of response is:
{
"error": {
"code": "string",
"message": {
"lang": "string",
"value": "string"
},
"innererror": {}
}
}
Which leads me to the point that I am not able to distinguish which Projects were successfully updated and which not.
Is there any way in oModel.update in error callback function to access the URL/ ID of the project of the request so I will be able to figure out which project this error is about?
Quick & similar example:
When I call:
for (var i = 0; i < aProjects.length; i++){
oModel.update("/ProjectSet('" + aProjects[i].id + "')", oChangedValues, {
method: 'MERGE',
success: function(oResponse){
},
error:function(oError){
// how can i access aProjects[i].id here of the one that was just called
// simply so i will know to which projectid this error corresponds
}
})
}
can you assign a different value to changeSetId for each of your request, check if it makes any difference.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm not really sure what do you mean? What exactly would it give me? I can send the requests with different changeSetId and I can even create object/array where I will map changeSetId to ProjectID but how in error callback will I be able to access changeSetId/ProjectID to know exactly which ProjectID failed (simply returned 4xx error but query itself isn't "failed")
check if you can get projectId in your error function callback.
for (var i = 0; i < aProjects.length; i++){
var projectId=aProjects[i].id;
oModel.update("/ProjectSet('" + aProjects[i].id + "')", oChangedValues, {
method: 'MERGE',
success: function(oResponse){
},
error:function(oError){
// how can i access aProjects[i].id here of the one that was just called
// simply so i will know to which projectid this error corresponds
}
})
}
Of course it is getting called. What I'm saying is:
Let's say I send 100updates to different projects (simply lets say i send batch with 100 requests), if one the updates goes into error callback how can I know which project id it was since this SAP API mentioned above does not return ProjectId.
The code is literally in the question:
for (var i = 0; i < aProjects.length; i++){
var projectId=aProjects[i].id;
oModel.update("/ProjectSet('" + aProjects[i].id + "')", oChangedValues, {
method: 'MERGE',
success: function(oResponse){
},
error:function(oError){
// how to access aProjects[i].id here -> if the loop run 100x and send 100 requests i simply want to know which ID went into error callback
}
})
}
User | Count |
---|---|
77 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.