How do I setup wfetch to send data to an HTTPS site? - iis

Why do I keep get this error when I use wfetch to connect to HTTPS sites?
0x80090329 (The specified data could not be encrypted.): [slib]: SealMessage
her is my log and my input body(input from base64 image encoded to string):
Accept: /\r\n
Content-Length:16437\r\n
Authorization: Basic bnBheWFwcDpucGF5YXBw\r\n
\r\n
0x80090329 (The specified data could not be encrypted.): [slib]: SealMessage0x80090329 (The specified data could not be encrypted.): Error On Receive/9j/4AAQSkZJRgABAQAAAQABAAD//gA7Q1JFQVRPUjogZ2QtanBlZyB2MS4wICh1c2luZyBJSkcgSlBFRyB2NjIpLCBxdWFsaXR5ID0gOTAK/9sAQwADAgIDAgIDAwMDBAMDBAUIBQUEBAUKBwcGCAwKDAwLCgsLDQ4SEA0OEQ4LCxAWEBETFBUVFQwPFxgWFBgSFBUU/9sAQwEDBAQFBAUJBQUJFA0LDRQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQU/8AAEQgA+gD6AwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/aAAwDAQACEQMRAD8A+o4ZvmSrqTfJWElyqVdhvF2V+nVInwESxeXny1n/AGnfTLmbe9V0hb71EY+6bljc1WIZqrojUfceqA2Ifnre01N61g2D73Sujs3RK8usdcTQhRUeti1vP4awnufmqxbea9eVKJ2RkdRbPvqW5mW2idt1ZlhM2+qXjC5lsNOfUFl2RQL829q4PZ89XlNZz5Ic5Kmtrc/wt8tc/r3xC0/Srd1+aaVfk2ba8qufidqdyztBL9m3/d2fwVU1bxbaX+iO15uudSb5N+7btr6qhlMoyjKqfOVc0jKPLE6C8+LqzWvzLsfd9xK4LxV4kbWLh9jfI1c5M/z1E719VQwFOlLmifMV8bUq+5IN9Moor2OU80KfRTKOUB9Rb/np2+q/8dMCamUb6KACihKfVcwDkSnom2ipf4K0IkNop2yrdhpV5qt0ltZwNcy/3ErKdWEPemRClOfwFKiuoT4d69seWTSLlItu/wA11rP/ALEl/uVxLHYeXwzOqWFrr7J2vnfPVhLlUT/arH8//ap6Oz15MqR9fGRtWyNcvu3V0dtbRTW6KyrXOaPcqi7GrrdNTf8Adrx8QdlKQ9NBXYny1VudHVFdvKa621L5PvVFTDFxqmrqT/O+2seZ9lW/tm9fmaqMzrV04ESkWIb9kiqzDfs/3qyfOXZT0udlEqQcxupc09HrHS/WpUv99YypF8x0dtebE20ya5b+GsSG5/2qtpef7Vc0qRtzGrDc7PvVppctc2/3vnrl/t

Related

Accessing file using fileget url

I am trying to create file handler add in that uses provider hosted application to open custom file.
I have hosted app in heroku and until now i get request body in my application as follows when i open file from sharepoint.
{
resourceid: "https://{tenant}.sharepoint.com",
culturename: "en-US",
fileget: "https://{tenant}.sharepoint.com/_vti_bin/wopi.ashx/files/{fileid}/contents?access_token={token}",
fileput: "https://{tenant}.sharepoint.com/_vti_bin/wopi.ashx/files/{fileid}/contents?access_token={token}",
fileid: "{fileid}",
client: "SharePoint"
}
But when i request to get file content using fileget url. It throws 500 error with message
The URL is invalid for the current user or application.
What could be the way to access file content.
The URL seem to be correct.
What you can do is to see the file's URL properties by requesting CheckFileInfo.
Example:
GET https://{tenant}.sharepoint.com/_vti_bin/wopi.ashx/files/{fileid}?access_token={token}
And have a look at DownloadUrl and FileUrl. If any of the properties is set, use them to download the file.

Wallet Pass auto update web service using aws api gateway

I am working on a web service to update Apple Wallet passes using AWS Lambda/API gateway/NodeJS. The Apple wallet hit the api to get update pass but each time I am getting following error:
encountered error: Received invalid pass data (The pass cannot be read because it isn’t valid.)
I have tried the same URL in the browser to get the pass. The pass is downloading every time and its opening a valid pass every time. But its not working when Apple wallet hit the URL. I have tried same URL in Postman it gives me base64 instead of binary data.
I have tried to achieve the same functionality with NodeJS and deployed on heroku, its working properly with Wallet(also gives binary in Postman). But I need to use AWS Lambda/API gateway/NodeJS.
I am not sure, if AWS changing something while delivering binary data.
Any help on this is appreciated.
I just experienced this and spent hours trying to diagnose what was happening.
For anyone using AWS API Gateway & Lambda for their PassKit web service endpoints, there's a major "gotcha" (at least as of the date of my response) with how API Gateway's logic determines whether it needs to convert a response from base64 ==> binary.
If you inspect the request headers from Apple Wallet / PassKit, you'll see that the Accept header is */*.
API Gateway apparently iterates through the items in the request Accept header and determines if there is a match with any of the Binary Media Types you've defined under Your API Name > Settings. It will use the first match it finds and then, as you'd hope, convert the base64 string (from Lambda) to binary.
Here's the crazy part -- if you define application/vnd.apple.pkpass as one of your "please convert to binary" media types, requests from Apple Wallet / PassKit will not work. Why? Well, AWS (for whatever reason...) hasn't programmed */* to match any type ... it will literally only match */*.
As a result, the Accept header's */* will not match with application/vnd.apple.pkpass and your base64-encoded .pkpass response (from Lambda) will not be converted to binary, causing PassKit to choke + report errors.
TL;DR -- there is some goofiness with AWS API Gateway. To return PassKit pass data successfully, you need to add */* (not application/vnd.apple.pkpass) under Your API Name > Settings > Binary Media Types.

AWS Lambda fails to return PDF file

I have created a lambda function using serverless. This function is fired via API Gateway on a GET request and should return a pdf file from a buffer. I'm using html-pdf to create the buffer and trying to return the pdf file with the following command
let response = {
statusCode: 200,
headers: {'Content-type' : 'application/pdf'},
body: buffer.toString('base64'),
isBase64Encoded : true,
};
return callback(null, response);
but the browser is just failing to load the pdf, so I don't know exactly how to return the pdf file directly to the browser. Could'nt find a solution for that.
well, I found the answer.
The settings in my response object are fine, I just had to manually change the settings in API Gateway for this to work in the browser. I have added "*/*" to binary media types under the binary settings in API Gateway console
API GATEWAY
just log into your console
choose your api
click on binary support in the dropdown
edit binary media type and add "*/*"
FRONTEND
opening the api url in new tab (target="_blank"). Probably the browser is handling the encoded base 64 response, In my case with chrome, the browser just opens the pdf in a new tab exactly like I want it to do.
After spending several hours on this I found out that if you set Content handling to Convert to binary (CONVERT_TO_BINARY) the entire response has to be base64, I would otherwise get an error: Unable to base64 decode the body.
Therefore my response now looks like:
callback(null, buffer.toString('base64'));
The Integration response:
The Method response:
And Binary Media Types:
If you have a gigantic PDF, then it will take a long time for Lambda to return it and in Lambda you are billed per 100ms.
I would save it to S3 first then let the Lambda return the S3 url to the client for downloading.
I was having a similar issue where pdf where downloaded as base64 and started happening when changed the serverles.yml file from:
binaryMediaTypes:
- '*/*'
to
binaryMediaTypes:
- 'application/pdf'
- '....other media types'
The issue is because the way AWS implemented this feature. From aws documentation here:
When a request contains multiple media types in its Accept header, API
Gateway honors only the first Accept media type. If you can't control
the order of the Accept media types and the media type of your binary
content isn't the first in the list, add the first Accept media type
in the binaryMediaTypes list of your API. API Gateway handles all
content types in this list as binary.
Basically if the first media type contained in the accept request header is not in your list in binaryMediaTypes then you will get base64 back.
I checked the request in the browser and the first media type in the accept header was text/html so I got it working after changing my settings to:
binaryMediaTypes:
- 'application/pdf'
- '....other media types'
- 'text/html'
Hope this helps anyone with the same issue.
Above solution is only for particular content-type. You can't more content type.
Follow only below two-step to resolve multiple content type issue.
Click on the checkbox of Use Lambda Proxy integration
API gateway --> API --> method --> integration request
Create your response as
let response = {
statusCode: 200,
headers: {
'Content-type': 'application/pdf',//you can change any content type
'content-disposition': 'attachment; filename=test.pdf' // key of success
},
body: buffer.toString('base64'),
isBase64Encoded: true
};
return response;
Note* - It is not secure
Instead of doing all this. It's better to use serverless-apigw-binary plugin in your serverless.yaml file.
Add
plugins:
- serverless-apigw-binary
custom:
apigwBinary:
types:
- "application/pdf"
Hope that will help someone.

File not supported error while uploading profile image file to IBM Connections using REST API

I'm trying to upload a jpeg file for profile image using the Profiles REST API to IBM Connections_v5.0. I however get an error message "The type of the photo file you provided is not supported".
I'm however able to upload the same file directly using the Connections UI interface directly. I'm setting the MIME type correctly as "image/jpeg".
Also tried with GIF and PNG images but get the same error message.
Any pointers would be very helpful.
I'm just using FF restclient addon to fire a REST call. So basically doing a PUT on /profiles/photo.do?key=....
Content-Type is set as "image/jpeg" and the payload consists of the image data in binary (base 64) encoded.
The payload should just be the binary of the image, there is no need to Base64 encode it.
You should refer to Adding a Profile Photo
You need to use a Key (great stackoverflow post here)
If you know the key for a user's profile you can do the following:
key — This is generated by Connections itself during the population
process. It is used to define the users profile within the context of
Profiles and provides Connections with the ability to associate
content with a user when the users LDAP information has been altered.
It provides a separation of identity and helps facilitate user content
synchronization for Connections.
Once you have a key, you make the following request
URL: https://profiles.enterprise.example.com/profiles/photo.do?key=
b559403a-9r32-2c81-c99w-ppq8bb69442
METHOD: PUT
CONTENT-TYPE: image/png
input the binary content on the stream
you should be able to use "image/jpeg", "image/jpg", "image/png" or "image/gif"
If you have an error after the PUT method, you should add the SystemOut.log lines which are relevant.

HttpContext.RewritePath breakes buildin IIS gzip

Hello.
I am using HttpContext.RewritePath to direct request to inner site folders depending from request and host.
Problem:
When I do any request that requires RewritePath for any static file that is cached and GZIPped by IIS, I get in response original non-compressed file content with Content-Encoding: gzip header, which leads to “Content decoding has failed” error.
But when I do same request but with full directory path (in that case RewritePath is skipped in my code) I get right gzipped content with Content-Encoding: gzip.
E.g.:
Situation with error:
Request url: localhost/lib/ext_3.4.0/resources/css/ext-all.css
Request path is rewrited using HttpContext.RewritePath to: localhost/_sites/mainSite/lib/ext_3.4.0/resources/css/ext-all.css
First response is not gzipped - usual IIS behavior. When I press ctrl+F5, I get “Content decoding has failed” error. By using Fiddler2 I can see that response content is not gzipped and it contains Content-Encoding: gzip header.
Situation without error:
Request url: localhost/_sites/mainSite/lib/ext_3.4.0/resources/css/ext-all.css
Request path is not rewrited because it is not needed.
First response is not gzipped again. When I press ctrl+F5, I get normal file content. By using Fiddler2 I can see that response content is gzipped, size is 5 times less and it contains Content-Encoding: gzip header.
I can't throw away RewritePath and I need IIS gzip. Is there any way to make them friends?

Resources