Page 1 of 1

API Breaks when query string has encoded new line

Posted: Fri Feb 14, 2025 1:42 am
by Alantod17
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>

Re: API Breaks when query string has encoded new line

Posted: Fri Feb 14, 2025 2:13 am
by SimproAPITeam
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

Re: API Breaks when query string has encoded new line

Posted: Tue Feb 18, 2025 10:20 pm
by Alantod17
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.

Re: API Breaks when query string has encoded new line

Posted: Fri Feb 21, 2025 12:05 am
by SimproAPITeam
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

Re: API Breaks when query string has encoded new line

Posted: Mon Feb 24, 2025 12:22 am
by Alantod17
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?

Re: API Breaks when query string has encoded new line

Posted: Tue Feb 25, 2025 8:57 pm
by Alantod17
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

Re: API Breaks when query string has encoded new line

Posted: Fri Feb 28, 2025 4:48 am
by SimproAPITeam
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

Re: API Breaks when query string has encoded new line

Posted: Mon Mar 03, 2025 1:28 am
by Alantod17
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?

Re: API Breaks when query string has encoded new line

Posted: Wed Mar 05, 2025 6:20 am
by Alantod17
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?

Re: API Breaks when query string has encoded new line

Posted: Fri Mar 07, 2025 5:49 am
by SimproAPITeam
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