cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Request attribute: convert collection to string?

gmichels
Guide

Hello,

 

I am configuring a request attribute based on a .NET Method, looking to extract the return value of this:

 

        public static ICollection<ErrorCode> GetErrors(this SearchResponse response)
        {
            if (response.ContainsError())
            {
                return (from error in response.Response.Errors
                    where null != error.RejectReason
                    select new ErrorCode
                    {
                        Code = error.RejectReason.Code,
                        Description = error.RejectReason.Description
                    }).ToList();
            }

            return null;
        }

Doing a simple toString() on the return value yields the object name, not the contents.

 

Is there a way for me to access the contents of that collection and print them out in a request attribute?

 

Thank you

2 REPLIES 2

bobby_crumley
Dynatrace Mentor
Dynatrace Mentor

Hey Gmichels. Do you have a toString() in the code base? Dynatrace will try to invoke the toString you specify to try to get the string out. In theory, as long as you yourself can cast something to the string, you can call Dynatrace to use the toString. If that doesn't work, try adding a String var1 = content.toString(); and then accessing var1 with the request attribute.+

 

Thanks - 

 

Bob Crumley

Hi Bobby, thanks for your reply. Unfortunately I can't change the code, so I was looking for some ways around it.

 

Thanks

Featured Posts