Automation - Web Request - URL parsing

lcrusan May 18, 2022

Hello,

I created a web request automation and this works:

https://dev.azure.com/instance/team/_apis/wit/workitems/$Bug?api-version=7.1-preview.3

However, this does not:

https://dev.azure.com/instance/team/_apis/wit/workitems/$Product Backlog Item?api-version=7.1-preview.3

I believe the spaces in "Product Backlog Item" are breaking the call. Is this a bug or feature? In either case is there a workaround?

Thanks

1 answer

1 accepted

3 votes
Answer accepted
Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 18, 2022

Hi @lcrusan and welcome to the community!

Yes, spaces are an issue with URLs so I would try encoding the spaces with something like this:

https://dev.azure.com/instance/team/_apis/wit/workitems/$Product%20Backlog%20Item?api-version=7.1-preview.3
lcrusan May 18, 2022

That did it, thanks!

Like # people like this
Ankit Rastogi August 8, 2023

Hi @Mark Segall ,

we can do this work around if we have static value. But in my case, I am getting value from smart variable like - {{issue.summary}}. Any idea how we can handle spaces in endpoint URL if spaces come in this variable.

Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 8, 2023

Hi @Ankit Rastogi - There are two options for this:

  • {{issue.summary.urlEncode}}
    • This will convert the spaces to "+" which may or may not solve your need.
  • {{issue.summary.replace(" ","%20")}}
    • This will replace spaces with the %20 that is common in URLs
Like Ankit Rastogi likes this
Ankit Rastogi August 8, 2023

Thanks a lot, @Mark Segall for very quick response.

 

I forget to mention, some special characters are also coming in variable so second option would not work I think. I tried first option by below way- 

use in endpoint - {{issue.summary.value.urlEncode}}

and it converts my URL by space with '+' , ' (' with '%28' and ')' with '%29'

But not sure it is giving 404 - Not found.

Because I used same on postman that also not working because on postman working without encoding - with spaces and special character in endpoint

Do you have any clue?

Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 8, 2023

I just tried combining the two options in my test environment and it works:

{{issue.summary.urlEncode.replace("+","%20")}}
Like Ankit Rastogi likes this
Ankit Rastogi August 8, 2023

Great, thanks a lot, @Mark Segall 

Working with - {{issue.summary.value.urlEncode.replace("+","%20")}}

 

Means just added value in your solution.

 

Thanks a lot, Sir!

Like Mark Segall likes this
Ankit Rastogi August 16, 2023

Hi @Mark Segall ,

 

I am facing one more issue, If I am sending a multiline description with POST API payload, my API is breaking. It is working with single line. Do you have any idea in case how we can send {{issue.description}} variable?

Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 17, 2023

Hi @Ankit Rastogi 

I would recommend creating a new question for this one.  I must admit that API work is not my strongest skill and it would bring more exposure to the community to have this one as a new question.  When you go this route, I would also recommend sharing a screenshot of your current payload (obfuscating any sensitive information of course).

Ankit Rastogi August 17, 2023
Like Mark Segall likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS
AUG Leaders

Atlassian Community Events