Uploader to handle Json response

2 Answers 91 Views
Upload
MiDAS
Top achievements
Rank 1
Iron
Iron
MiDAS asked on 11 May 2023, 08:05 PM

I am utilising the Kendo Uploader which is hitting a .net Frameworks api. The endpoint saves the file and then using the Telerik Doc library will open the uploaded spreadsheet and a validation begins where each row is validated against a set of rules. If any row fails to validate then details of the failure are recorded as a list. Once all rows have been checked the error list is returned as a json response. If the sheet validates without error the code will then save each row as a new record and return a json result confirming the number of records saved or if saving fails then an error as a json result.

I need to be able to process the json response on the client side via the onSuccess or onError events or some other way. Is this possible

Many Thanks

2 Answers, 1 is accepted

Sort by
0
MiDAS
Top achievements
Rank 1
Iron
Iron
answered on 18 May 2023, 02:34 PM

e.response.body contains the json I returned.....

public successEventHndl(e: SuccessEvent) {
    //~ console.log('e.response.body:' + JSON.stringify(e.response.body));
    this.cNNSaveMsg = new MsgToUser(e.response.body.Status, 6000, false,
e.response.body.Title, e.response.body.Message, "", "");
    this.ShowNotification(this.cNNSaveMsg);
  }

 

0
Martin
Telerik team
answered on 23 May 2023, 07:42 AM

Hi MiDAS team,

The error and success events of the Upload component can be used to inject any custom code when the upload or remove operation failed or is completed (the list of all available events of the component can be found here).

When an error occurs and the event is emitted, the ErrorEvent object is passed to the event handler containing the HttpResponse the type of operation that failed (upload or remove), and the files involved.

The same is valid for the success event but the type of object returned by the event is SuccessEvent.

Regards,
Martin
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources
Tags
Upload
Asked by
MiDAS
Top achievements
Rank 1
Iron
Iron
Answers by
MiDAS
Top achievements
Rank 1
Iron
Iron
Martin
Telerik team
Share this question
or