Smartservice REST body issue

Home Forums kbmMW Smartservice REST body issue

This topic contains 2 replies, has 2 voices, and was last updated by  kimbomadsen 7 months, 2 weeks ago.

  • Author
  • #53396



    First of all happy 2019!

    For one reason or another the body parameter in the following method is not marshalled into the  TSomeTest object.

    [kbmMW_Rest(‘method:post, path:”some-test”‘)]
    function AddSomeTest([kbmMW_Rest(‘value:”body”‘)] const ATest: TSomeTest): string;

    The TSomeTest looks like this:

    [kbmMW_Root(‘some_test’, [mwrfIncludeOnlyTagged])]
    TSomeTest = class
    FMyName: string;
    FMyAge: integer;
    property MyName: string read FMyName write FMyName;
    property MyAge: integer read FMyAge write FMyAge;

    I have added the following code in the initialization section

    TkbmMWRTTI.EnableRTTI([TSalesInvoice, TSalesInvoiceRead, TSomeTest]);
    kbmMWRegisterKnownClasses([TSalesInvoice, TSalesInvoiceRead, TSomeTest]);

    When I make a http post request with Fiddler I get an invalid type cast exception.

    I found out that I do have access to the body parameter, so I think that some goes wrong with marshalling. If I just marshal/unmarshal with TkbmMWJSONMarshal(m).ValueFromString etc. it does work fine.

    Any suggestion what might be the cause of this exception?

    I am using kbmmw

    Thanks in advance.


    p.s. the subject line input has a white font on a white background here in Firefox and Chrome


  • #53399


    I looks like the mime type var never makes it to the UmarshalBody method in kbmMWSmartServiceUtils.

    My http header looks like this:

    User-Agent: Fiddler
    Mime-Type: application/json
    Content-Length: 39

    Am I doing something wrong or is this a bug?

    • #53401



      You will definitely want to use latest versions for these features, as they continue to improve.

      It should work in 5.07, and it is definitely working in the 5.07.10 update that I will be releasing shortly.

      // This method gets a person in the body and echoes it back again.
      // Since we want the provided value echoed right back we dont want
      // the framework to free the argument automatically.
      // The result is freed when needed.
      [kbmMW_Rest(‘method:post, path: “echoPerson”‘)]
      function EchoPerson([kbmMW_Rest(‘value: “body”, free:false’)] const APerson:TPerson):TPerson;

You must be logged in to reply to this topic.