Suraj Yedre
Suraj Yedre

Reputation: 1

Expression inside set-body policy not working

I dont know what i am doing wrong but expression inside to fetch value form variable is not working in set-body policy inside send-request policy. Same thing works in return response. Scenario is I have to make 2 call where i will be passing data form first call as input to 2nd call. E.G

<set-body template="liquid">
                        <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
                            <soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
        
                            </soap:Header>
                            <soap:Body>
                                <tem:GetSomething>
                                    <tem:contactId>
                                    @{ context.Variables.GetValueOrDefault<string>("ContactId").ToString(); }
                                    </tem:contactId>
                                </tem:GetSomething>
                            </soap:Body>
                        </soap:Envelope>
                    </set-body>

Here In ContactId is the variable I have created which contains value from the first call output. I am getting below error for above snippet line

**'There was an error deserializing the object of type System.Guid. The value '
                                    @{ context.Variables.GetValueOrDefault&lt;string&gt;("ContactId").ToString(); }
                                    ' cannot be parsed as the type 'Guid'.'.  Please see InnerException for more details.**

Can anybody tell what is missing

Upvotes: 0

Views: 769

Answers (1)

user5534585
user5534585

Reputation:

from Codit Blog

Accessing the context variable

The context variable is also accessible from within Liquid templates. There’s a similar object model, compared to C# expressions, however the syntax is different. As an example, reading a query string parameter in C# works like this: @(context.Request.Url.Query.GetValueOrDefault(“orderId”, “”)). Inside the Liquid template, you need to apply the following notation: {{context.Request.Url.Query[“orderId”]}}.

Upvotes: 1

Related Questions