Question
· Nov 5, 2021

ERROR #9406

I'm trying to send a POST request to my REST API and I'm getting this error and most likely due the lack of experience, I have no idea how to fix this issue:  

"error": "ERROR #9406: Unexpected format for value of field, AlertText, using class base mapping",

            "id": "JSONImportError",

            "params": [

                "AlertText",

                "class base"

            ]

Am I missing something from my string definition?

Defined below as:

Class User.RESTComponents Extends (%Persistent, %JSON.Adaptor, %Populate)

{

Property AlertText As %String;

 

Here is my POST -method:

/// Creates a new User.RESTComponents item

ClassMethod POSTService() As %Status

{

    #dim tSC As %Status = $$$OK

    #dim e As %Exception.AbstractException

    Set test = ##class(User.RESTComponents).%New()

    Set data = %request.Content

    $$$TOE(tSC,test.%JSONImport(data))

    $$$TOE(tSC,test.%Save())

 

    Set %response.Status = 204

    Set %response.ContentType = ..#CONTENTTYPEJSON

    //d data.%ToJSON()

    Do test.%JSONExport()

 

    Quit tSC

}

Product version: IRIS 2021.1
Discussion (4)1
Log in or sign up to continue

Okay, so I figured out that I was missing a little more code from my POST -method

Needed to change: 

Set data = %request.Content ==> Set data = {}.%FromJSON(%request.Content)

This got me past my previous error and to the next one, which is as follows:

"ERROR #5035: General exception Name 'READ error while reading input stream' Code '10' Data ''"