0

I am currently experiencing something strange with one of my routes' responses and haven't been able to find any information elsewhere.

So, let's say I make a call to a route in my controller with JQuery, like this. It's a POST action and I expect JSON data.

// Send the data
            $.ajax({
                type: "POST",
                enctype: 'multipart/form-data', //'application/json',  
                url: "/Claims/Application/SaveCurrentFormData",
                data: data,
                dataType: 'json', // we're expecting back a json
                processData: false,
                contentType: 'application/json',
                cache: false,
                timeout: 600000,
                success: function (result) {                      
                    for (var formCode in result.forms) {
                        var selector = "[data-formcode='" + formCode + "']";
                        $(selector + " [name='TicketDocumentId']").val(result.forms[formCode]);
                    }

                    for (var documentName in result.documents) {
                        var selector = "input[name='" + documentName + "']";
                        $(selector).data("ticketdocumentid", result.documents[documentName]);
                    }

                    resolve(true);
                },
                error: function (e) {
                    // Debug
                    console.log("Error saving form data: ", e.message, e);

                    resolve(false);
                }
            });

On my method, I process some data and send a serialized version of the resulting data object:

// Build results object
saveResults.Add("forms", newForms);
saveResults.Add("documents", newDocs);

string dataJson = JsonConvert.SerializeObject(saveResults);

// Return a list of updated ticket documents with their respective IDs
return Content(dataJson);

A few days ago is when I originally wrote this. It was working, I was getting my JSON data back on the client. But something happened, I'm not sure when, and now all I get as a response is a literal "500". Please take a look at the screenshot:

https://imgur.com/a/oyRWtNg

I've tried using "return Json(saveResults)", and also different combinations, like expecting text instead of JSON in my POST action, and things like that. The thing is that no matter what I do, the response is always the same: "500". The status code is "200", though, so I don't really understand...

Any pointers would be greatly appreciated. This is a critical moment in the development of this project and I can't wait too long to fix this. :(

3
Contributors
3
Replies
24
Views
2 Months
Discussion Span
Last Post by pty
0

I can't seem to find the "edit" option, but I wanted to add that even if I return Content("test"), I still get the same response body of "500" with a status of 200. So it doesn't seem to be anything related to the data I'm trying to return.

Edited by Arwym

0

Sounds like a bug in the API to me. Did you write the backend too?

I'd use a tool like HTTPie/cURL so you can accurately and repeatably test requests

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.