Prevent trimming space after comma in header

I need to generate a header like the following to authenticate with a service provider:

 

RequestDate: Thu, 05 Dec 2019 13:57:07 -0500

 

but Apigee is trimming the space after the comma so the header becomes

 

RequestDate: Thu,05 Dec 2019 13:57:07 -0500

 

 I'm seeing the same behavior when using an AssignMessage or a Javascript policy. Is there a way to prevent this or otherwise address it within Apigee?

Solved Solved
1 2 98
1 ACCEPTED SOLUTION

I'm not seeing that.  I use an AssignMessage policy to set the formatted date and the upstream system receives it in the way I would expect:

requesteddate : Mon, 01 Aug 2022 21:06:56 +0000

Here's my policy: 

<AssignMessage name='AM-1'>
  <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
  <AssignVariable>
    <Name>timeformat1</Name>
    <Value>EEE, dd MMM yyyy HH:mm:ss Z</Value>
    <!-- eg "Tue, 15 Feb 2022 10:01:45 +0000"  -->
  </AssignVariable>

  <AssignVariable>
    <Name>formattedTime</Name>
    <Template>{timeFormatUTCMs(timeformat1,system.timestamp)}</Template>
  </AssignVariable>

  <AssignVariable>
    <Name>request.header.requesteddate</Name>
    <Ref>formattedTime</Ref>
  </AssignVariable>

</AssignMessage>

View solution in original post

2 REPLIES 2

I'm not seeing that.  I use an AssignMessage policy to set the formatted date and the upstream system receives it in the way I would expect:

requesteddate : Mon, 01 Aug 2022 21:06:56 +0000

Here's my policy: 

<AssignMessage name='AM-1'>
  <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
  <AssignVariable>
    <Name>timeformat1</Name>
    <Value>EEE, dd MMM yyyy HH:mm:ss Z</Value>
    <!-- eg "Tue, 15 Feb 2022 10:01:45 +0000"  -->
  </AssignVariable>

  <AssignVariable>
    <Name>formattedTime</Name>
    <Template>{timeFormatUTCMs(timeformat1,system.timestamp)}</Template>
  </AssignVariable>

  <AssignVariable>
    <Name>request.header.requesteddate</Name>
    <Ref>formattedTime</Ref>
  </AssignVariable>

</AssignMessage>

Thank you @dchiesa1! I was relying on output from the debug console and it was indicating that the space was trimmed. I set it to an upstream server where I could observe the request and I can confirm that the space is not trimmed.