ablFilter error - can not find out whats wrong...

Posted by noekleb on 22-Jan-2018 03:46

This gives error 400 and no logfile:

http://localhost:8080/CarkWeb/rest/ProdService/Prod?filter={%22ablFilter%22:%22prodnr%20=%20%27209215%27%22}

This gives error 500 and a entry in the logfile:

http://localhost:8080/CarkWeb/rest/ProdService/Prod?filter=%22ablFilter%22:%22prodnr%20=%20%27209215%27%22

18/01/22@10:40:54.007+0100] P-010820 T-009988 1 AS-12 -- (Procedure: 'ReadProd Prod' Line:250) Filter: {"ablFilter":"prodnr = '209215'"}
[18/01/22@10:40:54.008+0100] P-010820 T-009988 1 AS-12 -- ablFilter must be a quoted constant or an unabbreviated, unambiguous buffer/field reference for buffers known to query . (7328)
[18/01/22@10:40:54.008+0100] P-010820 T-009988 1 AS-12 -- Unknown attribute prodnr = '209215'. (3538)
[18/01/22@10:40:54.008+0100] P-010820 T-009988 1 AS-12 -- Failed to auto-prepare an automatic fill query. (11981)
[18/01/22@10:40:54.008+0100] P-010820 T-009988 1 AS-12 -- FILL of buffer ttprod with user-supplied query requires that the query be QUERY-PREPARED. (11876)

/*------------------------------------------------------------------------------
Purpose: Get one or more records, based on a filter string
Notes:
------------------------------------------------------------------------------*/
@openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="false").
@progress.service.resourceMapping(type="REST", operation="read", URI="?filter=~{filter~}", alias="", mediaType="application/json").
@openapi.openedge.method.property (name="mappingType", value="JFP").
@openapi.openedge.method.property (name="capabilities", value="ablFilter,top,skip,id,orderBy").
METHOD PUBLIC VOID ReadProd(
INPUT filter AS CHARACTER,
OUTPUT DATASET dsprod):

/*Filter = REPLACE(filter,'?filter=','').*/

MESSAGE 'Filter: ' filter
VIEW-AS ALERT-BOX.

IF filter BEGINS "~{" THEN
THIS-OBJECT:JFPFillMethod (INPUT filter).

ELSE
DO:
BUFFER ttProd:HANDLE:BATCH-SIZE = 0.
BUFFER ttProd:SET-CALLBACK ("AFTER-ROW-FILL", "AddIdField").
SUPER:ReadData(filter).
END.

END METHOD.

Posted by noekleb on 22-Jan-2018 15:34

It works :)

Thanks

All Replies

Posted by egarcia on 22-Jan-2018 05:28

Hello,

The HTTP error 400 Bad Request happened because curly braces { } cannot be used directly in the query string.

They need to be encoded:

{ -> %7B

} -> %7D

What is your client?

Is it JavaScript based?

If your client is JavaScript, you can use the function encodeURIComponent() to encode the characters.

Example: encodeURIComponent(JSON.stringify(filter))

Related Links:

meta.stackexchange.com/.../curly-brackets-in-urls

bz.apache.org/.../show_bug.cgi

The Error 500 happened because in the absence of the curly braces, ablFilter was being interpreted as a field in the database table.

Your query should work once you add the encoded characters.

localhost:8080/.../Prod

I hope this helps.

Posted by noekleb on 22-Jan-2018 15:34

It works :)

Thanks

This thread is closed