Good afternoon. Love the module and using it often. I am running into an error with the body of a POST request function wherein the API I am interacting with (distech) requires the body to be a ‘jsonArray’ and no matter how I format the body, it’s being sent as a ‘json Object’.
The format is something like this:
Body: |
[
{
key: value,
key: value,
key: value
},
{
key: value,
key: value,
key: value
},
{
key: value,
key: value,
key: value
}
]
If I submit like above, the exception comes from the module saying json strings must begin with ‘{‘
Your body isn't valid JSON as your array (the value) needs to be assigned to a key. I don't know what they're expecting, so could be something like this:
{
key: [
{
key: value,
key: value,
key: value
},
{
key: value,
key: value,
key: value
},
{
key: value,
key: value,
key: value
}
]
}
Oh, I think I see what you're saying....they want it to be formatted without the external object and pass just the array.
Would something like this work assuming your json object is named jsonObj:
jsonArr = jsonObj['key']
I haven't used the module, but didn't know if you could just pass a variable as the body.
Otherwise, your body looks like it would be OK in terms of how it's formatted.
It's possible the module itself is expecting it to begin with curly braces as a validation check. (Have you tried just tacking on the front/back opening/closing curly braces to see if it will take it?
I have. The configuration is written in YAML. I’ve tried several combinations and anything formatted as a class json Object returns an error from the targeted API which says essentially “json object could not be formatted as json array”. So I assume it’s something to do with the module and was hoping a fix might be a simple matter. Fingers crossed.
As I’m writing this it’s occurred to me that I haven’t tried submitting it in a YAML sequence, which might allow coercion into a json array… something like
Update: (next morning)
No dice. If there is a quick edit that can allow json Arrays to be passed into a body of a request, that is without the required '{', that would be incredible!
i have this API to send notification through httpsclient (Post) . Api code created as a function and execute it through tag change script and working fine ..
i am trying to create Yaml field to be used through api client module and always failed ..
Any guidance to convert this to Yaml as reference . Thanks
I'm trying to setup my yaml, but I keep getting this error message in the logs. Anyone know what it means? I know the session_token I am using is good.
net.dongliu.requests.exception.RequestsException: java.security.UnrecoverableKeyException: Get Key failed: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
at net.dongliu.requests.utils.SSLSocketFactories._getCustomSSLSocketFactory(SSLSocketFactories.java:53)
at net.dongliu.requests.utils.SSLSocketFactories.getCustomTrustSSLSocketFactory(SSLSocketFactories.java:61)
at net.dongliu.requests.executor.URLConnectionExecutor.doRequest(URLConnectionExecutor.java:127)
at net.dongliu.requests.executor.URLConnectionExecutor.proceed(URLConnectionExecutor.java:46)
at net.dongliu.requests.InterceptorChain.proceed(InterceptorChain.java:22)
at net.dongliu.requests.RequestBuilder.send(RequestBuilder.java:409)
at com.kyvislabs.api.client.gateway.api.functions.FunctionExecutor._execute(FunctionExecutor.java:68)
at com.kyvislabs.api.client.gateway.api.functions.FunctionExecutor.execute(FunctionExecutor.java:183)
at com.kyvislabs.api.client.gateway.api.functions.FunctionExecutor.run(FunctionExecutor.java:209)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.runAndReset(Unknown Source)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.security.UnrecoverableKeyException: Get Key failed: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
at java.base/sun.security.pkcs12.PKCS12KeyStore.engineGetKey(Unknown Source)
at java.base/sun.security.util.KeyStoreDelegator.engineGetKey(Unknown Source)
at java.base/java.security.KeyStore.getKey(Unknown Source)
at java.base/sun.security.ssl.SunX509KeyManagerImpl.(Unknown Source)
at java.base/sun.security.ssl.KeyManagerFactoryImpl$SunX509.engineInit(Unknown Source)
at java.base/javax.net.ssl.KeyManagerFactory.init(Unknown Source)
at net.dongliu.requests.utils.SSLSocketFactories._getCustomSSLSocketFactory(SSLSocketFactories.java:50)
... 14 common frames omitted
Caused by: javax.crypto.BadPaddingException: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
at java.base/com.sun.crypto.provider.CipherCore.unpad(Unknown Source)
at java.base/com.sun.crypto.provider.CipherCore.fillOutputBuffer(Unknown Source)
at java.base/com.sun.crypto.provider.CipherCore.doFinal(Unknown Source)
at java.base/com.sun.crypto.provider.PBES2Core.engineDoFinal(Unknown Source)
at java.base/javax.crypto.Cipher.doFinal(Unknown Source)
at java.base/sun.security.pkcs12.PKCS12KeyStore.lambda$engineGetKey$0(Unknown Source)
at java.base/sun.security.pkcs12.PKCS12KeyStore$RetryWithZero.run(Unknown Source)
... 21 common frames omitted