- switch:
version: 2.0.0
title: switch
case:
- condition: ($storageType() = 'binary')
execute:
- gatewayscript:
version: 2.0.0
title: gatewayscript
source: |-
context.message.body.write('in binary');
context.message.header.set('Content-Type', "*/*");
- condition: ($storageType() = 'stream')
execute:
- gatewayscript:
version: 2.0.0
title: gatewayscript
source: |-
context.message.body.write('in stream');
context.message.header.set('Content-Type', "*/*");
- condition: ($storageType() = 'json')
execute:
- gatewayscript:
version: 2.0.0
title: gatewayscript
source: |-
context.message.body.write('in json');
context.message.header.set('Content-Type', "*/*");
- condition: ($storageType() = 'xml')
execute:
- gatewayscript:
version: 2.0.0
title: gatewayscript
source: |-
context.message.body.write('in xml');
context.message.header.set('Content-Type', "*/*");
- otherwise:
- gatewayscript:
version: 2.0.0
title: gatewayscript
source: |-
context.message.body.write("in otherwise");
context.message.header.set('Content-Type', "*/*");
I have a request that is posting to the API with the above switch policy:
curl --location 'https://my-api.net/test-switch' \
--header 'Content-Type: text/plain' \
--data '@/C:/PathToFile/notes.txt'
What I found, is regardless of the request body content, the above as well as the curl statements below returns `in stream`.
curl --location 'https://my-api.net/test-switch' \
--data '{
"status":"here"
}
curl --location 'my-api.net/test-switch' \
--data '<?xml version="1.0" encoding="UTF-8" ?>
<status>here</status>
'
What am I doing wrong?
------------------------------
EIS Developer
------------------------------