How to set filename in $_FILES global from Mirth Connect - file-upload

I'm uploading a PDF using Mirth Connect. I've set the destination to a HTTP sender. The Content type is multipart/formdata and the body is just $(message.rawData).
I'm using a debugger and I can see the request successfully coming in. However the $_FILES array is structured like this:
{
"e00ce2d3-9bc4-4ce4-a923-2f5aecb1e5fc7756866505906950154_tmp": {
"name": "e00ce2d3-9bc4-4ce4-a923-2f5aecb1e5fc7756866505906950154.tmp",
"type": "multipart/form-data",
"tmp_name": "/tmp/phpJhm8Bf",
"error": 0,
"size": 32840
}
}
My problem is that I would like to use the original file name as the key for the $_FILES array. Is this possible using Mirth, or maybe is that name an encoded version of the original?
I know there are ways around this, I could add the original name as query parameter, but just out of curiosity I would like to know if it's possible to change the name of the key of the file upload.

If you're using File connector, then you can use the "originalFilename" source map variable. you can just reference it like this:
${originalFilename}

Related

Can BigQuery report mismatched the schema field?

When I upsert a row that mismatches schema I get a PartialFailureError along with a message, e.g.:
[ { errors:
[ { message: 'Repeated record added outside of an array.',
reason: 'invalid' } ],
...
]
However for large rows this isn't sufficient, because I have no idea which field is the one creating the error. The bq command does report the malformed field.
Is there either a way to configure or access name of the offending field, or can this be added to the API endpoint?
Please see this Github Issue: https://github.com/googleapis/nodejs-bigquery/issues/70 . Apparently node.js client library is not getting the location field from the API so it's not able to return it to the caller.
Workaround that worked for me: I copied the JSON payload to my Postman client and manually sent a request to REST API (let me know if you need more details of how to do it).

Can I include the all JSON paths required in a JSON file and use it inside my feature file for match or anything else?

For eg, I save paths.json and add the following. I know there is a mistake in the way i try, but not able to find it
{
"name": "JSON Path's",
"description": "This mainly store the paths of the JSON elements which are validated in each scenario",
"SC_4": {
"appHeader": "$.testResponse.applicationHeader",
"ProductsAction": "$.testResponse.applicationHeader.item.action"
}
}
* def attributes = read('../jsonpaths/paths.json')
Given url endPointURL
And request baseJsonRequest
When method post
Then status 200
* def appHeaderSecondTry = attributes.SC_4.appHeader
* print appHeaderSecondTry
Wow you are getting to be a power user of Karate so soon :P
Okay, personally I don't recommend trying to build a mini-framework over Karate like you are doing, I can see what you are trying to do - keep all assertions "declarative" and try to re-use common code for the actual HTTP call etc.
My opinionated take on this is, you save very few lines of code (because of how easy it is to make an HTTP request in Karate). Also, you should be able to re-use a feature file via the call keyword. I would urge you to try and keep the match statements "normal" in your tests.
That said, what you are missing is the karate.eval() operation, look for it in the doc. Here is an example (line 91): js-arrays.feature

What value actually need to provide {item-path} in view.delta OneDrive for Business API

I am using /drive/root:/{item-path}:/view.delta for getting the changes of a file in OneDrive for Business in root folder. I have tried with the path like /drive/root:/Files/filename:/view.delta but the response is resource not found. Can someone please explain what exactly this value ?
The link I am following is below.
more details
The error would suggest that /Files/filename does not exist, however even if it did you'd run into another limitation of how view.delta currently works with OneDrive for Business. To make a long story short, it's limited to only working on the root of the drive, i.e. /drive/root/view.delta. Using this path you'll get back changes for ALL items within the drive, not just the one that you're interested in.
Given that you're trying to detect changes in a single file you may want to consider a standard metadata request with an If-None-Match header that contains the ETag of the last state your application saw.
For example, you'd first make a request without any additional headers to get the initial state:
Request:
GET /_api/v2.0/drive/root:/File/filename
Response:
200 OK
{
...
"name": "filename",
"etag": "\"aasdfasdf\"",
"modifiedDateTime": "2016-01-01T00:00:00Z",
...
}
At some point in the future you'd then make a call using the etag value in the If-None-Match header:
Request:
GET /_api/v2.0/drive/root:/File/filename
If-None-Match: "aasdfasdf"
Response:
304 Not Modified
If the file has actually changed you'd get back the new response.
Request:
GET /_api/v2.0/drive/root:/File/filename
If-None-Match: "aasdfasdf"
Response:
200 OK
{
...
"name": "filename",
"etag": "\"poihklhjl\"",
"modifiedDateTime": "2016-04-19T00:00:00Z",
...
}

OneDrive API. moving a file to a root of an account. Doesn't work

I try to use onedrive REST API to manage my files
I want to move file. Move operation works for all cases except "move to root". If i move to some folder then all is fine. If i want to move root then i use the "me/skydrive" as the ID of the folder. but it doesn't work
example,
MOVE https://apis.live.net/v5.0/file.68b01a2d7f7f7d7c.68B01A2D7F7F7D7C!39188
(
[destination] => me/skydrive
)
Response
{
"error": {
"code": "request_parameter_invalid",
"message": "The value of input resource ID parameter 'destination' isn't valid. The expected value for this parameter is a resource ID for one of these types: 'folder'."
}
}
how to solve this? what should be the 'destination'
You'll want to use the folder id for the root drive to move the file. To find the folder id for the root drive, make a GET request for "me/skydrive". The JSON response will return the id that you will want to use for the MOVE request.
Just to add some official sources to the answer:
Note: When moving items to the root of a OneDrive you cannot use the "id:" "root" syntax. You either need to use the real ID of the
root folder, or use {"path": "/drive/root"} for the parent reference.
Source: https://dev.onedrive.com/items/move.htm

Is it possible to POST associations using "finder" URIs in Spring Data REST?

I would like to POST to create entities using associations that specify "finder" URIs rather than "identity" URIs. Is this possible?
POST this:
{
"username": "gonzo",
"role": "http://x.com/roles/nameequals?name=admin"
}
NOT this:
{
"username": "gonzo",
"role": "http://x.com/roles/1"
}
When I try this I get an error from Spring REST "failed to convert from type java.lang.String to type java.lang.Long for value 'name'" which I guess means it's not supported. I was hoping that there was some way of enabling this feature. Though that's probably wishful thinking.
Cheers
No, that's not supported. The URI needs to identify an item resource as we extract the backend ID from the URI directly to invoke findOne(…) on the repository.