Power Automate error when trying to add an attachment array from plumsail - attachment

I have a Plumsail form where a user can attach several pdf or word documents. In power automate I create an array of these documents and then attach the array to the "Start and wait for approval" action. When I run it, I get the error below:
The request failed. Error code: 'InvalidRequestContent'. Error
Message: 'The request content was invalid and could not be
deserialized: 'Could not find member 'ContentBytes' on object of type
'ApprovalsConnectorAttachment'.

I'm assuming you followed the How to send an email from Plumsail form with Power Automate Plumsail guide as it tells you to assign the HTTP GET file response to a property named ContentBytes.
While this will work with the Send an Email (V2) action (from the guide) the Start and wait for an approval action expects a property named content content.
To fix the problem append the following object to the array (note the contentproperty):
{
"name": #{items('Apply_to_each_2')?['file']},
"content": #{body('HTTP')}
}
or as an image:

Related

PowerApps Custom Connector: How to POST binary data in request body?

Using Postman to test an API, I'm able to select Body/binary then choose an image file stored locally. Postman inserts binary data somehow into the request and I get a favorable response:
When trying to build this as a Custom Connector in PowerApps, I can't find any info on what the schema for the Body of the request should be.
When I try to add a generic {"body": ""} body to the connector with a string type of binary, I receive this error:
Specified swagger has the following errors: 'Definition is not valid. Error: 'Error : paths/~1prebuilt~1analyze/post/parameters/2/schema/properties/body : A schema with type/format 'string/binary' can only be at the top level of a body or formData parameter. '
I was running into the same problem.
Body:
""
When you have clicked Import, go to the request -> body -> body and click the three dots -> Edit.
Under Body, it will say "key-body-output". Click the three dots and click Edit.
Change Type to String (if not already) and change Format to Binary. Change Is required to Yes.
Update the connector and you can now use the custom connector with PowerApps by using ImageX.Image for the body property for example.

Serverless - Change the content before deploy

I'm using Serverless for working with our aws lambda / appsync.
For Error Handling, we are keep erro code with message in a json file. The Codes will be unique. Something like this:
//error-code.json
{
"1"": { code: 1, message: "Invalid User Input"},
"2"": { code: 2, message: "Invalid Input"},
//... so on
}
This wil lbe deploy as layer and all the lambda will use it. Issue is we cannot use it in the resolve template. There are some of the resolver will be only template file. These template files cannot access the json file nor can access the layer. How can I use the error-code.json here?
Solution 1:
Manually write the error code in templates and make sure there are alway unique. Something like this:
#set(#errorInfo = {
"erroCode": "1",
"errorMessage": "Invalid Input"
})
$util.error("Invalid Input", "errorType", $ctx.arguments,#errorInfo)
Rejected: Becasue we have to manually check everytime for the unique of error code. In case of lot of template file, we cannot rely on it.
Solution 2:
Create a table with error code (unique) and error message. Use this table to send error from template.
Rejected: Because we use multiple app sync instance and they all connect to dirferent database. So we have to make this table in all database, and thus unique across the app-sync is not maintained.
Solution 3:
Write the placeholder in vtl where we want to send the error. Before Deploy, replace the placeholder with the actual code using pre-hook script, but not in the actual vtl file but in the generated package that serverless deploy. Does Serverless even such thing?
if your errors are all static, there is one more option for consideration.
You create one more file that holds all errors defined in Velocity.
$util.qr( $ctx.stash.put("errors", {}) ) $util.qr(
$util.qr( $ctx.stash.errors.put("ONE", { "code": 1, "message": "Invalid User
Input"} )
...
$util.qr( $ctx.stash.errors.put("TWENTY", { "code": 20, "message": "20th error description"} )
For every velocity resolver that throws errors, you inject pre-defined errors at the beginning of its request mapping's file. Whenever you want to throw an error, it's done by retrieving a pre-defined error from $ctx.stash
$util.error ( $ctx.stash.errors.ONE.message, $ctx.stash.errors.ONE.code )
The error file is generated from error-code.json, or manually typed again for simplicity. $ctx.stash is used because stash is accessible from everywhere in a resolver, including pipeline ones.

Best way to send XML results from a curl

we have a Jenkins pipeline that sends a sh 'curl' request to a an api/application to runs specific tests for us, and we fail/pass the build depending on the results.
What I want to do: is to parse the information we get back from the curl (XML document) and send these notifications via Slack.
What I've done so far is exactly that, parse the XML document, able to print the results locally, but when I try to send this result to slack I get a error: I am assuming this is because I saved my results as an Array, and when I am trying to send the information to slack its unable to reference the variable.
My question is: How should we send XML results to Slack and how can we properly parse the XML file and send it to slack?
My code snippet:
List <String> someString = new ArrayList<String>()
parsed = new XmlSlurper().parse("${workspace}/tmp/TESTS-results.xml")
parsed.testsuite.testcase.each { device ->
someString.add(device.#name)
someString.add(device.#time)
someString.add(device)
println deviceArr
println deviceArr.getClass()
}
parsed= XmlUtil.serialize(parsed)
return deviceArr
}
in field groovy.lang.GString.values
in object org.codehaus.groovy.runtime.GStringImpl#40198fcc
in field groovy.lang.Closure.delegate
in object org.jenkinsci.plugins.workflow.cps.CpsClosure2#4a4ae500
in field org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.closures
in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup#5dd0e25c
in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup#5dd0e25c
Caused: java.io.NotSerializableException: groovy.util.slurpersupport.Attributes

How do I use the messages file to create my own messagesApi

In my play-framework application, there is a messages file which I can use to define my own messages. Eg
##############Application Error messages
error.incorrectBodyType=Incorrect body type. Body type must be JSON
error.incorrectBodyContentInLoginRequest=No Login info found in the request. Check format
error.incorrectUsernameOrPassword = Incorrect username or password
error.unregisteredUser = registration not complete
error.ghostUsername = No record found for the username
error.unauthenticated = You must first sign in
error.unauthorized = You are not permitted
####### Application Success Messages
success.signoutSuccessful = Signout Successful
The play frameworks makes these messages available to my Controller and I can use them like the messagesApi("error.unauthenticated")(langs.availables(0)).
I am unable to figure out how I can use the messages file in my unit tests. I am using compile time injection and am creating my own instances of the required classes. To create MessagesApi, there is a DefaultMessagesApi method but it take a map, not a File.
I am able to create the messages in my unit tests as follows but I have to duplicate the effort of copying messages from messages file to this map
val messagesApi = new DefaultMessagesApi( //takes map of maps. the first is the language file, the 2nd is the map between message title and description
Map("en" -> //the language file
Map("error.incorrectBodyType" -> "Incorrect body type. Body type must be JSON",
"error.incorrectUsernameOrPassword"->"Incorrect username or password",
"error.incorrectBodyContentInLoginRequest"->"No Login info found in the request. Check format", //map between message title and description
"error.unregisteredUser" -> "registration not complete",
"error.ghostUsername" -> "No record found for the username",
"success.signoutSuccessful" -> "Signout Successful",
"error.unauthenticated" -> "You must first sign in",
"error.unauthorized" -> "You are not permitted")
)
)
Is there a way I can read the messages file and use it in my test case?
My test case already extended OneAppPerSuiteWithComponents. I used components.messagesApi of OneAppPerSuiteWithComponents which was already available and reads from the messages file

404 response when creating a course with the API

I am attempting to create a course with the API, and no matter how I tweak what I am sending I keep getting back the same 404 error. I am posting the following to /d2l/api/lp/1.4/courses/ in our test instance.
{
"Name":"STLR Course-112",
"Code":"STLR.112.201420",
"Path":"",
"CourseTemplateId":22462,
"SemesterId":22460,
"StartDate":"2014-05-07T12:00:00.000Z",
"EndDate":"2014-05-07T13:00:00.000Z",
"LocaleId":null,
"ForceLocale":false,
"ShowAddressBook":false
}
I can confirm with a test instance here that this API works with data almost identical to the block you provide here. POSTing a body like this (white space added for clarity):
{"CourseTemplateId": 8082,
"LocaleId": null,
"Code": "STLR.112.201420",
"Name": "STLR Course-112",
"Path": "",
"ShowAddressBook": false,
"EndDate": "2014-05-07T13:00:00.000Z",
"StartDate": "2014-05-07T12:00:00.000Z",
"ForceLocale": false,
"SemesterId": 6984}
Gets me a 200 with a response like this (white space added for clarity):
{"Identifier":"114119",
"Name":"STLR Course-112",
"Code":"STLR.112.201420",
"IsActive":true,
"Path":"/content/enforced/114119-STLR.112.201420/",
"StartDate":"2014-05-07T12:00:00.000Z",
"EndDate":"2014-05-07T13:00:00.000Z",
"CourseTemplate":{"Identifier":"8082",
"Name":"ExtensibilityTemplate",
"Code":"EXT-TMPL"},
"Semester":{"Identifier":"6984",
"Name":"Fall 2011",
"Code":"FA2011"},
"Department":{"Identifier":"8081",
"Name":"Extensibility",
"Code":"EXT"}
}
It appears to me that the only differences between my input block and yours are the IDs provided for course template and semester, so that I could hook the new course into my local test instance instead of the IDs for those orgunits in yours. Otherwise, it appears the input properties are identical.
Some things you could look at:
Ensure you're using the right Org Unit Id values for your course template and your semester
Ensure that your LMS is configured to enforce content paths for new org units: this should then provoke the LMS to auto-create the path for you when you create a course offering; if you don't have content path enforcement on, then you might have to instead specify a valid content path for your course offering on create, and passing in an empty string probably won't be a valid path, and thus you might get a 404 back because the API service handler "can't find the content path" you've specified.
Is there a particular message that comes back with the 404?

Resources