I have an Azure Logic App that uses a Analyze Document for Prebuilt or Custom models (v3.0 API) action. The Custom Model is good, I can hit it with Postman with no issue.
When I try to get a PDF from Sharepoint and send it to the service, I get an error saying:
{
"error": {
"code": "InvalidRequest",
"message": "Invalid request.",
"innererror": {
"code": "InvalidContent",
"message": "The file is corrupted or format is unsupported. Refer to documentation for the list of supported formats."
}
}
}
I've tried:
Passing the Get file content directly to the Document/Image File Content input
Passing body('Get_file_content)['$content']
Passing concat('data:application/pdf;base64,',body('Get_file_content')['$content']
This one converts to PDF in a Base64-to-PDF tool so I know the Base64 is good
Then I found out that the service wants binary format:
Passing base64ToBinary(body('Get_file_content')['$content'])
Still no go
Why can I not send the file to the Form Recognizer service?
EDIT:
Thank you to #vijaya. They helped me see that the Document/Image URL parameter was not necessary. Leaving that blank and using the original Get File Content worked!
Issue is with content-type. You need to pass content-type along with content for analyze document. I have reproduced issue from my side and below are steps I followed,
Initially created logic app as shown below,
Logic app failed with error,
The file is corrupted or format is unsupported. Refer to documentation for the list of supported formats.
Next modified logic app as shown below,
In Compose action setting content as
outputs('Get_blob_content_(V2)')?['body']?['$content'] and passing content-type as application/pdf as we are dealing with pdf files.
In Analyze Document for Prebuilt or Custom models (v3.0 API) action, using outputs of compose in Document/Image File Content.
Logic app ran successfully as shown below,
Output of Analyze Document is as shown below,
Related
Bottom line is that I'm trying to download my order history data from Lowes.com. I'm assuming there's an API endpoint that can be used but I haven't figured out the method or maybe what parameters need passed to get a successful request.
I looked at using python and scrapy but I don't believe the format of the webpages are going to be easy to parse the data.
I have found references to APIs in some of the javascript code for the website and the mobile app. Some of the relevant urls I've found:
From website -
ORDER_HISTORY_USER: '/wcs/resources/store/%0/member/%1/orderhistory/v1_0' (from function named Conduit on www.lowescdn.com)
From mobile app:
"url": "https://lwssvcs.lowes.com/IntegrationServices/resources/mylowes/user/order/list/v1_0"
"url": "https://lwssvcs.lowes.com/IntegrationServices/resources/mylowes/user/order/instore/v1_0"
So far I've only attempted to use these links via a browser after logging into my account. Assuming I'm on the right path, what method should I use to successfully get the data?
Whatever data I want to send whether be a text file or a PDF am able to give but how do I give my desired name to the file ?? And what about other types of files ?? What should be the request header please give an example had a look at the API documentation but not getting it ...
It seems you're using a basic upload.
You can use the suggested answer in this SO post:
Use multipart upload and specify the tile in the metadata part
{
"title": "My File"
}
Types of files are called MiME types. You can see the supported MiME types here.
Check this Multipart Upload guide for more info.
Right now we have a web application which upload a file using multipart in spring . now we are converting it as a rest webservices with JSON to a mobile application. how to send file details to rest webservice controller using json.
Simple
This is stateless.
Send JSON similar to this:
{ "fileName" : "the file name",
"contents" : "the file contents"
}
Be sure to use JSON escaping of the file contents and the file name.
Not Great
This requires state (not a good thing for a rest controller).
Call1: Post to .../beginUpload
Description: starts a file upload.
Parameter:
filename
ReturnValue: some identifer (called FileId below).
Call2: Post to .../fileContents
Desciption: adds some contents to an already open file.
Call this one or more times until the file contents are fully transferred.
Parameters:
fileId, contents.
ReturnValue: success / failure
Call3: Post to .../endUpload
Description: ends a file upload.
Parameter:
fileId
ReturnValue: success / failure
Challenge: the rest server may need to timeout uploads that have not had a call to .../fileContents in x minutes.
Different
Have the mobile device send an email containing the file to be uploaded.
Implement something to monitor the emailbox to which the file upload emails are sent and do "the right stuff".
I am trying to download JSON data from a web application. The URL/API is static and I can use it to call the webpage that returns the data. There is a session variable parameter that needs to be added to the URL/API call to connect to the server and download the JSON data which is created when you launch the application, but times out if the application is not actively used. My current process is to open the developer tools, launch the web application and when the specific JSON request is made I copy the parameter value then add it to a script that mimics the page request and downloads the JSON data.
I am trying to avoid manually copying and pasting this session variable parameter. I want to be able to automatically capture the web request, parse out the value that I need, set a cookie on my machine and then pick up the cookie by a php script to initiate the JSON data download with the valid session value.
I have looked into creating an extension in chrome using the chrome.webRequest.onResponseStarted with the following code:
chrome.webRequest.onCompleted.addListener(function(details) {
console.log(details);
chrome.cookies.set(
{ url: "http://localhost/MySite/", name: "MyCookie", value: "Tested" }
);
}, {urls:["<all_urls>"]} );
This code works for the main web requests but it doesn’t pick up all the JSON data requests that are made by the application. The application is swf format which is most likely the problem, but I can see the requests in the Network Panel tab of the Developer Tools and they are captured using chrome://net-internals which that leads me to believe that I should be able to capture them somehow.
I have looked into chrome.devtools.network but I cannot seem to figure out how that is supposed to work. Any advice or direction would be greatly appreciated.
Please provide me some references to call WebScripts in alfresco remotely using JSON..
Alfresco has some default Webscripts ,I need to invoke these Webscripts in different Application remotely...
There is no documentation that I know of at the present time that documents all web scripts that expect JSON to be posted along with a schema that defines the expected JSON. Honestly, we haven't done a good job identifying which out-of-the-box URLs are actually public. Some are there just for the Share application's use and could change without warning.
With that said, you can go to http://localhost:8080/alfresco/s/index and see a list of web scripts. And if you drill down into the web script (click on the web script's ID), you can see the source code for the JavaScript controller or, if the web script is implemented in Java, you can see the full class name that implements it. You can then inspect the source to see what it is expecting.
Another way to do it is to use Firebug or your browser's developer console to watch the network calls that go from your browser to the repository tier. Many of these calls include JSON being posted to repository tier web scripts.
Assuming you're referring to getting a webscript to respond with a json, there are a few steps.
1. Create a webscript, and possibly set json the default format (in the webscript definition file, i.e. mywebscript.get.desc.xml, add a tag
<format default="json">argument</format>
Create a JSON controller too, ie. mywebscript.get.json.js. This script can do two things:
a) get json parameter (if you sent a json in): if (json.has('myparam')) myVar = json.get('myparam');
b) provide some data to the model, ie. model.docs = companyhome.children
Your webscript also needs to format this json for json response, i.e. mywebscript.get.json.ftl would look something like this:
{ "docs": [
<#list docs as doc> {
"name": "${doc.name}",
"prop": "${doc.properties["mymodel:myprop"]}"
} <#if doc_has_next>,</#if>
</#list>
]
}