Question

How to set XML attribute in post webhook (XML) payload?

  • 17 October 2023
  • 8 replies
  • 92 views

Userlevel 1

Hi,

I am using webhooks (post as XML) and use an unflattened data payload like this:

  • item: CREmployee__toPrefRegion1Node__CRDataNode
  • value: 100

It renders as follows:

</CREmployee>
    <toPrefRegion1Node>
        <CRDataNode>100</CRDataNode>
    </toPrefRegion1Node>
</CREmployee>

But I want it to be rendered like this:

</CREmployee>
    <toPrefRegion1Node>
        <CRDataNode id="100"/>
    </toPrefRegion1Node>
</CREmployee>

So how can I move the datavalue (100) to the “id”-attribute of the XML element “CRDataNode”?

 

Thank you for replying.


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

8 replies

Userlevel 7
Badge +14

Hi @raissa raissa 

Good question.

Can you link to the API documentation you are referencing to configure the Zap step?

Userlevel 1

Thank you Troy,

Yes sure! It’s mentioned here: https://help.zapier.com/hc/en-us/articles/8496083355661-How-to-Get-Started-with-Webhooks-by-Zapier#unflatten-nested-payloads-0-11

(In my case I use the XML-payload type instead of the JSON one)

Userlevel 7
Badge +14

@raissa raissa 

But what about the documentation you are referencing to know what XML structure to configure?

Userlevel 1

Hi @Troy Tessalone,

This is from the API interface of carerix.com (recruitment software supplier). You need a (developer) login to get access to the documentation but I’ve tested it with a piece of PHP-client code.

 

Userlevel 7
Badge +14

@raissa raissa

Can you post screenshots of the documentation for us to have context?

 

Otherwise we are limited in our ability to evaluate and advise.

Userlevel 1

@Troy Tessalone 

I couldn’t find the specific case, but here is a screenshot of how a certain employee is updated. Within the XML you see that the attribute “id” is used on the CRDataNode element.

Apart from this context, I just want to know (and how, if possible) whether I can setup attributes of XML elements in the payload.

 

 

Userlevel 7
Badge +14

@raissa raissa 

If you are using a PUT method request, have you tried using the exact provided XML structure as shown in the screenshot?

Userlevel 1

@Troy Tessalone 

Thank you for the hint. I’ve resolved it by changing the “event type” to custom event. That way I could build up the whole XML structure myself.

Thanks again!