Forum Discussion

nikita_1608's avatar
7 years ago

Can we have 2 POST calls in an endpoint?

Hi,

 

I'm calling an url of POST type in an endpoint with different twice.

But the response we are getting is of only one post call, that is the first one.

 

For example:

        <#attempt>
              <#assign imageURL = http.client.request("https://comunity.com/v1/pop/avatars/image").header("Ocp-Apim-Subscription-Key","key").body('${requestBody}',"application/json").post() />
				<#if imageURL.hasError>
                  <error>${imageURL.error.message}</error>
                  <error>${imageURL}</error>
                  <error>${imageURL.error}</error>
                <#else>
    				<#if imageURL.content??>
                      <#assign res=imageURL.content?eval />
                      <#assign url = res.url />
                      ${url}
                    </#if>
                </#if>
          <#recover>
          		Error
          </#attempt>
      
      ${parts_array[1]}
  
        <#attempt>
              <#assign imageURL1 = http.client.request("https://community.com/v1/pop/avatars/image").header("Ocp-Apim-Subscription-Key","key").body('${requestBody1}',"application/json").post() />
				<#if imageURL1.hasError>
                  <error>${imageURL1.error.message}</error>
                  <error>${imageURL1}</error>
                  <error>${imageURL1.error}</error>
                <#else>
    				<#if imageURL1.content??>
                      <#assign res1=imageURL1.content?eval />
                      <#assign url1 = res1.url />
                      ${url1}
                    </#if>
                </#if>
          <#recover>
          		Error
          </#attempt>

Could anyone help me with this?

 

Thanks

  • nikita_1608- Can you remove ${parts_array[1]} variable from your code. I couldn't find where you have defined this variable.

     

    Thanks

    Tariq Hussain

    • nikita_1608's avatar
      nikita_1608
      Guide

      Hi,

       

      That variable doesn't matter.

      When we try to hit the post call api using jquery making synchronous as well as asynchronous call, we get the same response for same call but with different response bodies.

       

      This behaviour is bit strange