web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Passing template value to external API through X++

(0) ShareShare
ReportReport
Posted on by 139

Hello,

I am working on integration requirement and consuming external API to interface external data.

External API used for creating file and fill data into file.

Below sample template we have set on postman to fill data in the created file

Template:

<#if addHeader == true>
Customer,Amount,OrderNumber,PaymTerm,Item<#lt>
</#if>

pastedimage1668241112824v1.png

I am looking for your help to setup template details through X++ 

I have tried below but get the error:

Sample code:

Method()

{

 System.Net.WebHeaderCollection  httpHeader;

str template = @'<#if addHeader == true>
Customer,Amount,OrderNumber,PaymTerm,Item<#lt>
</#if>;


httpHeader = new System.Net.WebHeaderCollection();
httpHeader.Add("name","application/x-www-form-urlencoded");
httpHeader.Add("ContentType","application/x-www-form-urlencoded");
httpHeader.add("template", template);

}

Error: Below error we have received on httpHeader.add("template",template) line of code

pastedimage1668241630100v2.png

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    239,678 Most Valuable Professional on at

    The error says that you shouldn't the header value (your 'template' variable) shouldn't contain line breaks.

  • Verified answer
    huijij Profile Picture
    19,813 on at

    Hi KomalG,

    As mentioned,you should check your variable if it contains special characters.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 635 Super User 2026 Season 1

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 635 Super User 2026 Season 1

#3
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 547

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans