So we have a requirement to upload file to sharepoint server using iOS client . We are able to upload file size till 40kb but the problem is the file data we are passing is in Base64 encoding,and it fails for file size more than 40kb because we cannot pass large data in soap message,so we tried different approaches possible and mentioned on web . These are the ways we tried out
and we are left with only sending data using MTOM .
After lots of experiments and search I think MTOM is a way to upload data using soap . We are using CopyIntoItems sharepoint service for upload .
Soap request looks like
<"xmlns:soap12=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
"<soap12:Body>\n"
"<CopyIntoItems xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\">\n"
"<SourceUrl>%#</SourceUrl>\n"
"<DestinationUrls>\n"
"<string>%#</string>\n"
"</DestinationUrls>\n"
"<Fields>\n"
"%#"
"</Fields>\n"
"<Stream>MY_FILE_DATA</Stream>\n"
"</CopyIntoItems>\n"
"</soap12:Body>\n"
"</soap12:Envelope>\n"
Now the problem is how do we format this soap request in the way MTOM accepts,because CopyIntoItems may not work in some other format.
Few samples of MTOM which i looked into
http://pic.dhe.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.wsfep.multiplatform.doc/info/ae/ae/cwbs_soapmtom.html
http://cxf.apache.org/docs/mtom.html
Any help would be much appreciated..Thanks..!!
What about using HTTP post and developing an Http handler to store posted data?
It is quite easy to setup an http handler in Sharepoint (MSDN) and in the Process request method you can use query string to get the information you need.
Say you create an Upload.ashx handler.
public void ProcessRequest(HttpContext context)
{
var targetList = context.Request["targetList"];
var targetFileName = context.Request["targetFn"];
// Get the stream to content
var stream = context.Request.GetBufferedInputStream();
// Save the file somewhere
}
From the client you do an HTTP post to http://server/_layouts/15/Upload.ashx?targetList=myFiles&...
Related
I'm having some trouble getting a GET Action with body to work in BluePrism (using web api service).
It seems that when I try to include an Action that sends a GET with body when I reach that stage this error gets thrown:
Internal : Unexpected error Cannot send a content-body with this verb-type.
What I've tried:
Using a different verb-type / passing parameters in the query instead of the body, unfortunately i don't have control over the endpoint i'm trying to reach so this didnt work as it only accepts a GET containing data in the body
Using BluePrism HTTP Utility to send the call, this has the same problem as the Web API Service
Compiling the body via code instead of using a template
I haven't been able to find anyone that made it work in BluePrism and there doesn't seem to be much documentation on this issue in BluePrism so any help would be appreciated.
Thanks!
.NET's WebRequest class that Blue Prism uses under the hood to conduct
these requests will not allow you to send a request body with any GET
request. There is no (documented) way to overcome this limitation.
While other related answers on Stack
Overflow correctly state
that there exists no such prohibition on including request bodies with
GET requests per RFC
9110§9.3.1, it is
very unusual for a production-grade service to require that the request
itself include anything in the request body. It's also possible that
intermediaries like HTTP proxies may strip or otherwise mangle the request
body in transit anyway.
There is no out-of-the-box way to force the .NET Framework (which Blue
Prism uses) to send GET requests with a request body. If you're able,
you can install
WinHttpHandler
and implement it as a drop-in replacement for HTTPRequest (this SO
thread will help).
Because this type of solution requires the install of a new library, it's
important to consider the caveats of doing so:
Blue Prism's support for external DLLs is unstable at best, and there's
no guarantee it will even import correctly to begin with. Vendor support
for this type of setup is, anecdotally, limited to nonexistent (and
rightfully so, IMO).
If you're able to successfully implement the functionality described
with WinHttpHandler, you'll need to install it on every Blue Prism
developer's machine and runtime resource in all your environments
(development/SIT/UAT/production). For some organizations, strict IT
security posture makes this rather impractical or outright infeasible.
I managed to get it working using a code block containing C# code and using Reflection, here is a my GET method:
public string GetWithBodyAndAuth(string uri, string data, string token, out int statusCode)
{
var request = (HttpWebRequest)WebRequest.Create(uri);
request.Headers.Add("Authorization", "Basic " + token);
request.ContentType = "application/json; charset=utf-8";
request.Method = "GET";
request.Accept = "application/json";
var type = request.GetType();
var currentMethod = type.GetProperty("CurrentMethod", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(request);
var methodType = currentMethod.GetType();
methodType.GetField("ContentBodyNotAllowed", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(currentMethod, false);
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
{
streamWriter.Write(data);
}
var response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
statusCode = ((int)response.StatusCode);
return reader.ReadToEnd();
}
It's a bit of a hack and can't say if it'll be supported in the future, but for BluePrism 6.9 this allows you to send GET requests containing a body.
It has the advantage of not requiring any external DLLs, this is the import list:
I am trying to consume a soap web service, it works with soap ui but when I use node soap, it does not. I believe the problem is coming from sending a wrong body. This is the body that is to be sent to the web service and this works on soap ui.
<arg0><![CDATA[<C24TRANREQ><PROCESSING_CODE>07</PROCESSING_CODE>
<DR_ACCT_NUM>0711201711</DR_ACCT_NUM><TRAN_CRNCY_CODE>KSD</TRAN_CRNCY_CODE>
</C24TRANREQ> ]]></arg0>
In the object for node-soap, I simply send this below as the args object
const args = {
PROCESSING_CODE: 07,
TRAN_CRNCY_CODE: "KSD",
DR_ACCT_NUM: 0711201711
}
I want to believe my empty response is coming from not including arg0 and C24TRANREQ in my node-soap object. How do I include this?
Also are the numbers to be javascript strings or just numbers?
I'm currently developping an app based on Sharepoint REST API and Microsoft Graph. My app is composed mainly with a Tabbed Page, and on the first tab I want to display News from sharepoint. To do so I want to get images from the news, but using the url of the images as Image Source returns me "forbidden" error. So, I decided to find a way to download those images. I've been looking for a way for few days now, and found nothing...
Does anyone knows a way to do that, or why do I have a forbidden access error ?
I bring some precisions, I'm using an HttpClient to authenticate to the tenant with REST API :
client = new HttpClient();
Uri mUri = new Uri(App.ReturnUri);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var data = await DependencyService.Get<IAuthenticator>()
.Authenticate(App.LoginAuthority, App.RestResourceUri, App.ClientId, mUri);
App.AuthenticationResult = data;
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", App.AuthenticationResult.AccessToken);
From that, I hope someone knows if there is a way to download images, or to access to url in order to use them as Source. I succeeded in retrieving URLs but not displaying images, knowing that I can retrieve any other data from sharepoint
Thanks for any help,
The Image component can use a URL as its data, but that requires images that aren't behind an authentication which is probably the case with your SharePoint images. That is also why it's returning you a Forbidden error.
var webImage = new Image { Aspect = Aspect.AspectFit };
webImage.Source = ImageSource.FromUri(new Uri("https://xamarin.com/content/images/pages/forms/example-app.png"));
To add the authentication layer for SharePoint you would probably be able to implement your own UriImageSource implementation. In the end an ImageSource only needs a Stream object so getting that from either the internet or local storage would work.
To download and store images you will have to write code for both platforms specifically because local storage works differently. Check out this blog post as a starting point combined with your own piece of code.
https://blog.falafel.com/xamarin-forms-storing-and-retrieving-photos/
Hi in one of my response i am getting this xml
<root><err>0</err><errDesc></errDesc><state>3</state><p1>{C4739B96-E12A-429B-9A03-0B5B5F814D3C}</p1><p2>{1C33A258-D50E-4D44-8309-83665FC6073E}</p2><p5>1</p5><p6>QdjXQJy0SVnamdLJqMMHz/Cxtu8Dbw21q5caSX9uwoBlZDvBfHJx1R7QfknQ+f564YfmnEyRnJ1TJ5DF+ZOK2g==</p6><p7></p7><p8>{00000000-0000-0000-0000-000000000000}</p8><p9>0</p9><returnmessage></returnmessage></root>
I need to extract id between p6 tags and pass it as a cookie in subsequent request as CPSession.
How to achieve this in C# Web Performance Testing.
Any help would be hugely appreciated.
I am trying to write a web test request plugin and in its prerequest method i am trying to write a method to achieve this with following code
CookieContainer gaCookies = new CookieContainer(); Uri target = new Uri("http://susday4446.corp.ncr.com:8091/core/ui/uiBrowser.aspx");
> gaCookies.Add(new Cookie("CPSession", "QdjXQJy0SVnamdLJqMMHz/Cxtu8Dbw21q5caSX9uwoBlZDvBfHJx1R7QfknQ+f564YfmnEyRnJ1TJ5DF+ZOK2g==");
> { Domain = target.Host }
But this is not able to add cookie in this request.
Right now all i am trying to do is passing CPSession as a cookie its value i have hardcoded.
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.