API Breaks when query string has encoded new line

Posts about the simPRO API. Help/support/how-to etc.
Forum rules
  • Check the documentation first. Before posting questions, please check the documentation to ensure it doesn't already cover what you need.
  • No spam. All automated messages, advertisements, and links to competitor websites will be deleted immediately.
  • Post in relevant sub-forums only. Messages posted in the wrong topic area will be removed and placed in the correct sub-forum by moderators.
  • Respect other users. No flaming or abusing fellow forum members. Users who continue to post inflammatory, abusive comments will be deleted from the forum after two warnings are issued by moderators.
  • Harassment. No threats or harassment of other users will be tolerated. Any instance of threatening or harassing behavior is grounds for deletion from the forums.
  • Adult content. No profanity or pornography is allowed. Posts containing adult material will be deleted.
  • Bandwidth. All images and signatures must be 500 x 500 pixels or smaller. Posts containing over-sized images and signatures will be removed.
  • Illegal content. No re-posting of copyrighted materials or other illegal content is allowed. Any posts containing illegal content or copyrighted materials will be deleted.
Post Reply
Alantod17
Posts: 68
Joined: Thu Sep 26, 2019 12:50 am

API Breaks when query string has encoded new line

Post by Alantod17 » Fri Feb 14, 2025 1:42 am

Hi we are trying to call following Endpoint but get a 400 bad request error without any detail.

Code: Select all

https://wspservices.simprosuite.com/api/v1.0/companies/0/catalogs/?pageSize=250&Name=Order+Materials-4+x+adaptable+boxes%c2%a0Box+of+20mm+nylon+gland%c2%a0grey+or+white%0a1+x+A+4377A%c2%a0%e2%80%a2+Phase5+Public+Address+Mixer+Amplifier+125W+4+Input
The original name is
Order Materials-4 x adaptable boxes Box of 20mm nylon gland (grey or white)\n1 x A 4377A • Phase5 Public Address Mixer Amplifier 125W 4 Input

Pls note the \n1 is encoded but we still got 400 bad request

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>400 Bad Request</title>
</head>
<body>
<h1>400 Bad Request</h1>
</body>
</html>
SimproAPITeam
Posts: 831
Joined: Wed May 01, 2024 2:31 am

Re: API Breaks when query string has encoded new line

Post by SimproAPITeam » Fri Feb 14, 2025 2:13 am

Hi Alantod17,
Please try with the original name without the added + symbols.

This is an example which returns the correct result:

Code: Select all

/api/v1.0/companies/{companyID}/catalogs/?Name=test catalog item for name search
Regards
Simpro API Team | Simpro Software Group
Alantod17
Posts: 68
Joined: Thu Sep 26, 2019 12:50 am

Re: API Breaks when query string has encoded new line

Post by Alantod17 » Tue Feb 18, 2025 10:20 pm

Thanks for your response. However, the + symbols you’re seeing are simply a result of standard URL encoding.

Could you clarify how the Simpro API handles special characters in product names? Shouldn’t it follow the industry standard and decode the URL accordingly?

Looking forward to your thoughts.
SimproAPITeam
Posts: 831
Joined: Wed May 01, 2024 2:31 am

Re: API Breaks when query string has encoded new line

Post by SimproAPITeam » Fri Feb 21, 2025 12:05 am

Hi,
When submitted the URL encoding will be applied automatically, but when searching you should use the standard string format for it to be applied correctly. Based on the url included it seemed as you added the encoding before searching which would break.

I've tested on my build by naming one of my catalog items with the same name as you use and searched for the catalog item successfully using this search parameter below.

The name should be entered as shown on you catalog item without any special characters added.

Code: Select all

/catalogs/?Name=Order Materials-4 x adaptable boxes Box of 20mm nylon gland (grey or white)\n1 x A 4377A • Phase5 Public Address Mixer Amplifier 125W 4 Input
Regards
Simpro API Team | Simpro Software Group
Alantod17
Posts: 68
Joined: Thu Sep 26, 2019 12:50 am

Re: API Breaks when query string has encoded new line

Post by Alantod17 » Mon Feb 24, 2025 12:22 am

Hi

Thanks for the reply. if we not encode the query param before we send the request. what if there is an & sign in the name?

for example

/catalogs/?Name=Order Materials-4 x adaptable boxes Box of 20mm nylon gland (grey or white)\n1 x A 4377A • Phase5 Public Address Mixer Amplifier 125W 4 & Input & pagesize=250

how your API will know & Input is not another param?
Alantod17
Posts: 68
Joined: Thu Sep 26, 2019 12:50 am

Re: API Breaks when query string has encoded new line

Post by Alantod17 » Tue Feb 25, 2025 8:57 pm

SimproAPITeam wrote: ↑Fri Feb 21, 2025 12:05 am Hi,
When submitted the URL encoding will be applied automatically, but when searching you should use the standard string format for it to be applied correctly. Based on the url included it seemed as you added the encoding before searching which would break.

I've tested on my build by naming one of my catalog items with the same name as you use and searched for the catalog item successfully using this search parameter below.

The name should be entered as shown on you catalog item without any special characters added.

Code: Select all

/catalogs/?Name=Order Materials-4 x adaptable boxes Box of 20mm nylon gland (grey or white)\n1 x A 4377A • Phase5 Public Address Mixer Amplifier 125W 4 Input
Regards
Hi Any update on this problem pls? we about to roll out a release. it would be good if we can get this fixed before the roll out
SimproAPITeam
Posts: 831
Joined: Wed May 01, 2024 2:31 am

Re: API Breaks when query string has encoded new line

Post by SimproAPITeam » Fri Feb 28, 2025 4:48 am

Hi,
Ampersand (&) is a bit special as it's used for adding additional search parametes.

I've tested and you can escape & using %26 in the query.

So searching for this name:

Code: Select all

Order Materials-4 x adaptable boxes Box of 20mm nylon gland (grey or white)\n1 x A 4377A • Phase5 Public Address Mixer Amplifier 125W 4%26test

will return the result with actual name:

Code: Select all

Order Materials-4 x adaptable boxes Box of 20mm nylon gland (grey or white)\\n1 x A 4377A • Phase5 Public Address Mixer Amplifier 125W 4&test
Regards
Simpro API Team | Simpro Software Group
Alantod17
Posts: 68
Joined: Thu Sep 26, 2019 12:50 am

Re: API Breaks when query string has encoded new line

Post by Alantod17 » Mon Mar 03, 2025 1:28 am

SimproAPITeam wrote: ↑Fri Feb 28, 2025 4:48 am Hi,
Ampersand (&) is a bit special as it's used for adding additional search parametes.

I've tested and you can escape & using %26 in the query.

So searching for this name:

Code: Select all

Order Materials-4 x adaptable boxes Box of 20mm nylon gland (grey or white)\n1 x A 4377A • Phase5 Public Address Mixer Amplifier 125W 4%26test

will return the result with actual name:

Code: Select all

Order Materials-4 x adaptable boxes Box of 20mm nylon gland (grey or white)\\n1 x A 4377A • Phase5 Public Address Mixer Amplifier 125W 4&test
Regards
Hi, thanks for the information. However, it didn't quite answer my question.

Should we encode the URL before sending it, or not? Is there a specific list of special characters that we need to encode?

Also, is there any documentation available regarding this?
Alantod17
Posts: 68
Joined: Thu Sep 26, 2019 12:50 am

Re: API Breaks when query string has encoded new line

Post by Alantod17 » Wed Mar 05, 2025 6:20 am

Alantod17 wrote: ↑Mon Mar 03, 2025 1:28 am
SimproAPITeam wrote: ↑Fri Feb 28, 2025 4:48 am Hi,
Ampersand (&) is a bit special as it's used for adding additional search parametes.

I've tested and you can escape & using %26 in the query.

So searching for this name:

Code: Select all

Order Materials-4 x adaptable boxes Box of 20mm nylon gland (grey or white)\n1 x A 4377A • Phase5 Public Address Mixer Amplifier 125W 4%26test

will return the result with actual name:

Code: Select all

Order Materials-4 x adaptable boxes Box of 20mm nylon gland (grey or white)\\n1 x A 4377A • Phase5 Public Address Mixer Amplifier 125W 4&test
Regards
Hi, thanks for the information. However, it didn't quite answer my question.

Should we encode the URL before sending it, or not? Is there a specific list of special characters that we need to encode?

Also, is there any documentation available regarding this?
Any updates pls?
SimproAPITeam
Posts: 831
Joined: Wed May 01, 2024 2:31 am

Re: API Breaks when query string has encoded new line

Post by SimproAPITeam » Fri Mar 07, 2025 5:49 am

Hi,
Please note that this forum is not monitored every day. For urgent issues report to our Simpro help desk.

There is no specific documentation for this or list available of specific special characters.

If you are relying on searching for catalog names I recommend not using special characters in the name or test specific characters that you need to ensure you don't experience issues when querying the data.

Regards
Simpro API Team | Simpro Software Group
Post Reply