I have a requirement where user can pass document and it gets uploaded to an Appian's folder. I have created a WebAPI (Document Upload) and positive scenario is working as expected.
For Negative Scenario (When we are not passing any document):
1. In the WebAPI , it is handled as "400- Document not provided" but when testing we are getting status-200 (Untitled document from web API.txt).
Q. From where we are getting this "Untitled document from web API.txt" document. Where is it handled?
Q. How to fix default handling?
Discussion posts and replies are publicly visible
Did you consider to use a!isnullorempty() instead of isnull()? This is the more modern approach and manages more of the edge cases.
Yes Stefan Helzle ,
I did try and the result was same. I don't see anywhere documented that Appian will create a document by itself and upload it if no document was passed in the body.
Also, I don't see where "Untitled document from web API.txt" part is being handled in the webAPI.
Can you post the full HTTP request you send to Appian?
Need to see the body . Null or empty also gives false for empty array .If your body coming as a empty array it will go for true statement in that if condition
PFB, the requested details:
'Binary file load error: invalid or missing file source'POST https://**********.appiancloud.com/suite/webapi/upload-test-document: { "Network": { "addresses": { "local": { "address": "1**.1*.*.2", "family": "IPv4", "port":5***6 }, "remote": { "address": "7*.***.*.*5", "family": "IPv4", "port": 443 } }, "tls": { "reused": false, "authorized": true, "authorizationError": null, "cipher": { "name": "*******-RSA-******-***-SHA256", "standardName": "TLS_***********************", "version": "TLSv1.2" }, "protocol": "TLSv1.2", "ephemeralKeyInfo": { "type": "ECDH", "name": "prime256v1", "size": 256 }, "peerCertificate": { "subject": { "commonName": "*.appiancloud.com", "alternativeNames": "DNS:*.appiancloud.com, DNS:*.api.appiancloud.com, DNS:api.appiancloud.com, DNS:*.appiancloud-dynamic.com, DNS:appiancloud.com, DNS:appiancloud-static.com, DNS:appiancloud-dynamic.com, DNS:*.appiancloud-static.com" }, "issuer": { "country": "US", "organization": "Amazon", "commonName": "Amazon RSA 2048 M03" }, "validFrom": "Oct 9 00:00:00 2024 GMT", "validTo": "Nov 7 23:59:59 2025 GMT", "fingerprint": "****************************************************", "serialNumber": "*******************************************************************" } } }, "Request Headers": { "authorization": "Basic ************************************/", "user-agent": "PostmanRuntime/7.43.0", "accept": "*/*", "cache-control": "no-cache", "postman-token": "f0843694-4b38-42e7-b136-6460c0a14053", "host": "deloitteuk.appiancloud.com", "accept-encoding": "gzip, deflate, br", "connection": "keep-alive" }, "Request Body": "{ value: null }", "Response Headers": { "date": "Tue, 21 Jan 2025 06:24:36 GMT", "content-length": "61", "connection": "keep-alive", "x-trace-id": "d7cc7121e3fc79f2a26bbfa005e6fff7", "strict-transport-security": "max-age=31536000; includeSubDomains; preload", "referrer-policy": "strict-origin-when-cross-origin", "x-frame-options": "SAMEORIGIN", "content-security-policy-report-only": "style-src 'unsafe-inline' 'self' web-assets.appian-cdn.com 'strict-dynamic' 'nonce-OThjNjMzODEtN******************************'; child-src 'none'; script-src 'self' 'unsafe-inline' 'unsafe-eval' web-assets.appian-cdn.com 'strict-dynamic' 'nonce-ZDhlMTY1YzktMDBhNi00ZTMxLWFmZjUtYTNiMWMxZWUzNjg1'; object-src https:; frame-src https:; img-src https:; default-src 'self'; font-src 'self' https: data:; report-uri /suite/rest/a/logging/latest/csp/report; report-to report;", "content-security-policy": "report-uri /suite/rest/a/logging/latest/csp/report; report-to report;", "reporting-endpoints": "report=\"/suite/rest/a/logging/latest/csp/report\"", "x-xss-protection": "1; mode=block", "requested-while-authenticated": "false", "x-robots-tag": "none" }, "Response Body": "Upload Successful: 25222 - Untitled document from web API.txt"}
Hi Stephan,
Ideally it should go to error handling and should give "404- Document Not Found" if no document is sent.
But if you see the response it is generating a document by itself and giving as : "Response Body": "Upload Successful: 25222 - Untitled document from web API.txt"
Then you need to adapt your validation. It is not the body that is null or not, but your body contains a JSON structure and a field called "value" that is null or not.