7 Replies Latest reply on Nov 13, 2017 6:30 PM by shawkins

    Return data types in REST call

    shiloh.jordan

      Hi,

      I have a REST procedure in my view model that returns all of my column data as XML.  How can I return the datatypes of data along with the actual data?

       

       

      All help is appreciated

      Thanks,
      Shiloh

        • 1. Re: Return data types in REST call
          shawkins

          Are you looking to embedded xsi:type information, or do you have some other mechanism in mind?  Is this xml you are creating with SQL/XML?

          • 2. Re: Return data types in REST call
            shiloh.jordan

            Hi Steven,

            In the response body of the REST response, is there a way to return the datatypes of the data from the source model along with the data?

            In my example, the elements are being returned with the column name, but is there a way to return the data type with the name?

             

            Thanks,

            Shiloh

            • 3. Re: Return data types in REST call
              shawkins

              Here you showing the JSON result.  Simple type information in JSON is typically limited to just the literal values - "21" vs 21 for string vs numeric.  Are you looking to produce different JSON literal values?

              • 4. Re: Return data types in REST call
                shiloh.jordan

                Hi Steven,

                Yes, in my table, I have 3 different data types (string, int, and dateTime)

                 

                I would like to distinguish those types in my response.  It seems as though all of my types are coming back as string.  Is there a way to control this?

                • 5. Re: Return data types in REST call
                  shawkins

                  Can you provide more details on how the response is formed?  You initially mentioned xml.  What does the procedure definition look like?

                   

                  Differentiating between string and int should be possible, but dataTime is a problem in JSON as there is no standard literal.

                  • 6. Re: Return data types in REST call
                    shiloh.jordan

                    Hi Steven,

                    Here is my REST virtual procedure:

                     

                    Is there a way to return the datatypes in XML?

                    • 7. Re: Return data types in REST call
                      shawkins

                      Currently there is no additional logic in XMLELEMENT/XMLFOREST to add automatically add type information.  You would have to do this on your own. 

                       

                      If you are relying on an automatic conversion to json starting with the xml, then yes it would effectively loose the type information of literal values.

                       

                      If you directly create json, then at least numeric values would be as expected.

                      1 of 1 people found this helpful