What's the difference between SET & ADD elements in Assign Message Policy in Apigee Edge ?

Looks like more or less they are same. It's not very clear in docs that explains difference between them.

Anyone came across same & figured out why they are different ?

Solved Solved
3 3 5,265
2 ACCEPTED SOLUTIONS

Not applicable

Hi @Anil Sagar,


AFAIK the difference is that you can set the below attributes to a message in addition to the headers, query params, and form params which can be set using ADD elements too. (SET is a superset of ADD)

 <xs:element name="Payload" type="xs:anyType" minOccurs="0"/>
 <xs:element name="Verb" type="xs:string" minOccurs="0"/> 
 <xs:element name="Version" type="xs:string" minOccurs="0"/> 
 <xs:element name="Path" type="xs:string" minOccurs="0"/> 
 <xs:element name="StatusCode" type="xs:string" minOccurs="0"/> 
 <xs:element name="ReasonPhrase" type="xs:string" minOccurs="0"/>

View solution in original post

Maruti is correct; as far as configuration goes, "(SET is a superset of ADD)".

But there is a difference in operation.

Set will over-write any existing value.

Add will append to any existing value.

Let's consider HTTP Headers. Suppose there is an existing HTTP Header called "accountid", holding the value ABCDEFG . Now consider two scenarios. First, SET:

<Set>
  <Headers><Header name="accountid">1234567</Header></Headers>
</Set> 

Now, Add:

<Add>
  <Headers><Header name="accountid">1234567</Header></Headers>
</Add> 

The result of the former is an HTTP Header called "accountid" with value "1234567".

The result of the latter is an HTTP Header called "accountid" with value "ABCDEFG,1234567"

This example considers HTTP Headers, but the same is true for query params, form params, and so on.

If there is no existing value, then Set and Add are equivalent.

View solution in original post

3 REPLIES 3

Not applicable

Hi @Anil Sagar,


AFAIK the difference is that you can set the below attributes to a message in addition to the headers, query params, and form params which can be set using ADD elements too. (SET is a superset of ADD)

 <xs:element name="Payload" type="xs:anyType" minOccurs="0"/>
 <xs:element name="Verb" type="xs:string" minOccurs="0"/> 
 <xs:element name="Version" type="xs:string" minOccurs="0"/> 
 <xs:element name="Path" type="xs:string" minOccurs="0"/> 
 <xs:element name="StatusCode" type="xs:string" minOccurs="0"/> 
 <xs:element name="ReasonPhrase" type="xs:string" minOccurs="0"/>

Thank you @Maruti Chand , +1

Maruti is correct; as far as configuration goes, "(SET is a superset of ADD)".

But there is a difference in operation.

Set will over-write any existing value.

Add will append to any existing value.

Let's consider HTTP Headers. Suppose there is an existing HTTP Header called "accountid", holding the value ABCDEFG . Now consider two scenarios. First, SET:

<Set>
  <Headers><Header name="accountid">1234567</Header></Headers>
</Set> 

Now, Add:

<Add>
  <Headers><Header name="accountid">1234567</Header></Headers>
</Add> 

The result of the former is an HTTP Header called "accountid" with value "1234567".

The result of the latter is an HTTP Header called "accountid" with value "ABCDEFG,1234567"

This example considers HTTP Headers, but the same is true for query params, form params, and so on.

If there is no existing value, then Set and Add are equivalent.