Published on InterSystems Developer Community (https://community.intersystems.com)

Home > ERROR #9406

Question
Juuso Lepistö · 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

}

#REST API #InterSystems IRIS
Product version: IRIS 2021.1

Source URL:https://community.intersystems.com/post/error-9406