Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

Custom connector returns empty header

Dear community,

 

I'm currently trying to get a custom connector working due to an API returning information in the header of a response that is required to fetch all the data.

 

Initially, the following snippit of code worked and I got the same headers as when using postman

 

However, something has changed. I'm not sure what, but when I now test this, the only header I'm getting is  'content-type'....

I'm not really sure where to begin with this as postman is returning the proper values, and this has worked before and AFAIK I didn't change anything here ....

 

Hopefully somebody can point me in the right direction.

 

Kind regards,

 

Vincent

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    I think you may refer to blog as below to have a try.

    https://powerusers.microsoft.com/t5/General-Power-Automate/Custom-connector-action-with-x-www-form-u...

     

    1. Click "New Policy"
    2. Name your policy
    3. Select "Set HTTP header"
    4. Select the Operations (Actions) that require this header
    5. Header name: "content-type"
    6. Header Value: "application/x-www-form-urlencoded"
    7. Action if header exists: "override"
    8. Run policy on: "Request"

     

    Best Regards,

    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hey Rico,

       

      I did this, but this didn't make a difference. As I indicated earlier, it did work before and after deleting a method that I put before the original contents method I worked again. Also, I checked the raw data coming in and I could see that even when the connector didn't show me the headers. They actually were there, so there is a very odd bug at play here...

       

      kind regards,

       

      Vincent

  • Anonymous's avatar
    Anonymous
    Not applicable

    Dear Rico,

     

    Thank you for the reply, but I believe something else is at play here. At some point, I simply rebuild the connector, and all was fine again, that was untill I added a method at the very start of the connector ( so preceding the original contents method  ). After that, the response was mangled again. Interestingly, once  removed the method all was fine again. I've toyed around with a bit ( to try and get a feel for the problem ), but in the end I had deadlines so I focussed on getting it done so I don't have a complete reproduction ... but it's rather unstable when it comes to moving that first content method around ....

     

    kind regards,

     

    Vincent  

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous , I think you need to way that you have included you key in the Web.Contents function.  Try this instead.

     

    let
       AuthKey = "x-api-key = ####",
       Source = Web.Contents(url, 
            [
              Headers = 
                    [
                       Authorisation= AuthKey,
                       #"Content-Type"="application/json"
                    ],
              RelativePath = path,
              Content = Text.....    

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Dear Daryl,

       

      Thank you for the reply, but I'm afraid that's not it. As I mentioned below here, initially the connector worked ( returning me all the expected headers ). And actually, it is working again after I removed a method that I put before the original contents method. Another funny thing I noticed, when examining the raw data coming in, the headers are THERE...there're just not shown and/or recognized ....

       

      kind regards,

       

      Vincent