Get Website content type

Hello,
How can I get the content type of an url (e.g. text/plain)?
thank you,
Peter

java.net.URL url = ...;
java.net.URLConnection conn = url.openConnection();
String contentType = conn.getContentType();

Similar Messages

  • Getting invalid content type for SOAP: TEXT/HTML exception for Soap Adapter

    I am trying to invoke Webservice using SOAP Receiver Adapter
    but I am getting error
    <SAP:AdditionalText>com.sap.aii.af.ra.ms.api.DeliveryException: invalid content type for SOAP: TEXT/HTML</SAP:AdditionalText>
    Pls let me know
    Regards

    HI,
    see
    •     Q: What character encoding is supported by the SOAP sender adapter?
               A: The SOAP sender adapter can accept any character encoding supported by the local JDK. When you are using a particular character encoding with content type text/xml, you must make sure that the encoding name given in the content type and in the XML declaration must be consistent. What makes this more complex is that the default values. The default encoding for "text/xml" is US-ASCII, whereas the default encoding for the XML declaration is UTF-8 or UTF-16. The following examples show several valid combinations of content-type and XML declartion:
               text/xml
               <?xml version='1.0' encoding='us-ascii'?>
               text/xml; charset='utf-8'
               <?xml version='1.0' encoding='utf-8'?>
               text/xml; charset='utf-8'
               no declaration
               text/xml; charset='iso-8859-1'
               <?xml version='1.0' encoding='iso-8859-1'?>
               application/xml
               <?xml version='1.0' encoding='iso-8859-1'?>
               The response message from the SOAP sender is normally encoded in UTF-8. If you want to change this encoding, for instance to iso-8859-1, you can supply the encoding information with the xmlenc variable in the request URL as in:
               http://host:port /XISOAPAdapter/MessageServlet?channel=p:s:c&xmlenc=iso-8859-1
               Related Questions "What character encoding is supported by the SOAP receiver adapter?"
    Regards
    Chilla

  • SP 2013 Workflow Associations - get the content type for associated tasks with PowerShell

    I am creating a PowerShell script to document SharePoint 2013 workflow associations on a site. I can get the Subscription object for the workflow association, but I can't figure out how to dig into it to find out the Content Type for tasks generated
    by workflows created by this WF association. I can get the Task List ID from the Subscription.PropertyDefinitions, and from there can get the Task List. But the task list may use many different content types, because when you associate a 2013 workflow
    to a list, SharePoint adds the workflow's content type to the set of content types used by the workflow task list. If you have a lot of workflows that use the same task list, that task list gets a lot of content types.
    I have the Subscription object for the workflow association. How can I divine the content type for tasks that the workflow will generate?
    Leigh Webber

    I would suggest you to consider using the SPListItem that running the workflow instance to check the task content type.
    First, find the list item that associated with the workflow, then SPListItem.Tasks returns a collection of workflow tasks for the item, you can check the content type from the task item.
    Qiao Wei
    TechNet Community Support

  • How to get Custom-Content-type Column Value of a Document Library-Folder

    Hello
    I have to add a custom-column(folder-imageURL) for Folders in a Document Library.
    So I have created a Custom-CotentType "FolderCtype" with new column "folder-imageURL" and attached in the Document Library.
    Whenever I create a new folder in that document library I will select my "FolderCtype" & and then add an image url in "folder-imageURL" column.
    How do I access this image url in Code?
    part of my code is as follows.
    SPContentType cntType = List.ContentTypes["FolderCtype"];
    SPField field = cntType.Fields.GetField("folder-imageURL");  //I have Field name here//
     foreach (SPFolder folder in RtFolder.SubFolders)
                        if (folder.Name.ToUpper() != "FORMS")
                           string FolderName = folder.Name;
                          string FolderImageUrl = ?              //How can I get this????//
    Thanks in advance

    Hi, Patrickm, Thank You
    If your “folder-imageURL” column is a “Hyperlink or Picture” column, then you can get the hyperlink like this:
    SPListItem item = folder.Item;
    if (item[field.Title] != null)
    string FolderImageUrl = item[field.Title].ToString().Split(',')[0];
    Console.WriteLine(FolderImageUrl);
    Best regards,
    Patrick
    Patrick Liang
    TechNet Community Support
    S H A J A N

  • Get content type info

    Hello Friends,
    I have 4 list based content types which have a similar column "appendix" as single line of text. I have added them to my list. My requirement is, when I click on the new item and select the content type, I should get the content type info in the appendix
    column.
    Can someone help me on getting that info? I cannot use the InfoPath forms to get the information.
    Please suggest

    Hi ChandraShekhar
    You need to first go through the below links in-order to resolve you problem
    Content Types
    Indul Hassan
    Microsoft Community Contributor
    http://www.indulhassan.com
    You Snooze.. You Lose !!

  • Need to restrict content type

    Hi,
    In the standard check in page, I want to restrict the content type to only to "Documents" for all users except admin and sysadmin.
    For example : if a admin log in, should get all content type, but if a normal user comes should get only content type as "Document".
    And i guess, if it is to be implemented, on admin level will work for my website also.
    Need help on how to implement.
    Thanks,
    Abhijit

    You will have to modify the template of the standard checkin page. Alternatively, you could define Rules and Profiles for all but admin users and disable access to the standard checkin page. Read Bex Huff's book, chapter 9 how to do it (both).

  • Scrip to update Sharepoint Online content type

    I have a content type "TestContentType" with three columns:
    Document Type
    Category
    Sub-category
    This content type is used on 18 document libraries, in 3 site collections.
    The Category column needs to have a "description" added which currently has no description. Is there a way to achieve this via a script so I don't have to make change manually via the UI.
    So far I have come up with the following script, but this so far only lists all list and document libraries. What I actually need is to be able to get the content type in this case "TestContentType" and then update the "Category" column
    to include a description:
    $loadInfo1 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
    $loadInfo2 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")
    $webUrl = Read-Host -Prompt "HTTPS URL for the SP Online 2013 site"
    $username = Read-Host -Prompt "Email address login"
    $password = Read-Host -Prompt "Password for $username" -AsSecureString
    $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($webUrl)
    $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
    $web = $ctx.Web
    $lists = $web.Lists
    $ctx.Load($lists)
    $ctx.ExecuteQuery()
    $lists| select -Property Title
    Any suggestions would be appreciated.

    This isn't the best way to do it, which would be manipulating SharePoint through the CSOM, however you can automate IE so that it runs through a series of actions.
    The nice way would be to use something like the client-side code here:
    https://sharepointpowershell.codeplex.com/
     I don't have the time to dig into it at the moment but i'd try to merge that CSOM approach with something like this script:
    http://get-spscripts.com/2010/11/add-and-remove-site-content-types-from.html which uses the on-prem version.

  • Powershell to add/delete content type to particular library alone in a site collection

    Hi,
    I am trying to add and delete content type from a particular picture library (site collection) using powershell.
    I have tried the below, but it is not working.
    Below scenarios are not working:
    1) If the content type to be added is there in library, then the loop is still moving to "No content type exists".
    2) Content type is not getting deleted from library
    3) Set the newly added content type as default content type.
    Below is the powershell, which I am trying:
    function ChangeContentType($url)
    $site = Get-SPSite($url);
    $web =$site.RootWeb
    $lookForList = "PicLibrary"
    $lookForCT = "Img1ContentType"
    $lookForRemoveCT = "Image2CT"
    write-host "Checking site:"$web.Title
    #Make sure content types are allowed on the list specified
    $docLibrary = $web.Lists[$lookForList]
    if ($docLibrary -ne $null)
    $docLibrary.ContentTypesEnabled = $true
    $docLibrary.Update()
    if (($web.ContentTypes | where { $web.Name -eq $lookForCT }) -eq $null)
    write-host "No content type exists with the name" $lookForCT "on list" $docLibrary.Title
    #Add site content types to the list
    write-host "Adding content type " $lookForCT "on list" $docLibrary.Title
    $ctToAdd = $web.ContentTypes[$lookForCT]
    $ct = $docLibrary.ContentTypes.Add($ctToAdd)
    write-host "Content type" $ct.Name "added to list" $docLibrary.Title
    $docLibrary.Update();
    else
    write-host "content type exists with the name" $lookForCT "on list" $docLibrary.Title
    #Remove Content type
    if (($web.ContentTypes | where { $web.Name -eq $lookForRemoveCT }) -eq $null)
    write-host "No content type exists with the name" $lookForRemoveCT "on list" $docLibrary.Title
    else
    $ctToRemove = $web.ContentTypes[$lookForRemoveCT]
    write-host "Removing content type" $ctToRemove.Name "from list" $docLibrary.Title
    $docLibrary.ContentTypes.Delete($ctToRemove.Id)
    $docLibrary.Update()
    else
    write-host "The list" $lookForList "does not exist in site" $web.Title
    #Dispose object
    $site.Dispose()
    $web.Dispose()
    How to fix this?
    Thanks

    Hi,
    Thanks for the reply.
    I checked it. If the script is run multiple times, the add and delete content type will throw error.
    How to delete content type? I have tried the below:
    $docLibrary = $web.Lists[$lookForList]
    if ($docLibrary -ne $null)
    $docLibrary.ContentTypesEnabled = $true
    $docLibrary.Update()
    #get the content Type
    Write-host "Getting content type $lookForCT in site $web"
    #Confirm that the content type exists.
    $contentType = $web.ContentTypes | where {$web.ContentTypes.Name -eq $lookForCT}
    ##Abort if not found.
    if ($contentType -eq $null)
    Write-host "$lookForCT not found in site collection."
    else
    if ($web.ContentTypes.Name -eq $lookForCT)
    Write-host $docLibrary.ContentTypes.Name
    if($docLibrary.ContentTypes.Name -eq $lookForCT)
    write-host "Content type $lookForCT is already added to list" $docLibrary.Title
    else
    write-host "No content type exists with the name" $lookForCT "on list" $docLibrary.Title
    write-host "Adding Content Type"
    $ctToAdd = $web.ContentTypes[$lookForCT]
    $ct = $docLibrary.ContentTypes.Add($ctToAdd)
    $docLibrary.Update()
    write-host "Content type" $ct.Name "added to list" $docLibrary.Title
    #get the content Type
    Write-host "Getting content type $lookForRemoveCT in site $web"
    #Confirm that the content type exists.
    $contentType = $web.ContentTypes | where {$web.ContentTypes.Name -eq $lookForRemoveCT}
    ##Abort if not found.
    if ($contentType -eq $null)
    Write-host "$lookForRemoveCT not found in site collection."
    else
    if ($web.ContentTypes.Name -eq $lookForRemoveCT)
    Write-host $docLibrary.ContentTypes.Name
    if($docLibrary.ContentTypes.Name -eq $lookForRemoveCT)
    write-host "Content type $lookForRemoveCT is added to list" $docLibrary.Title.
    write-host "Removing Content type $lookForRemoveCT"
    $ctToRemove = $web.ContentTypes[$lookForRemoveCT]
    $docLibrary.ContentTypes.Delete($ctToRemove.Id)
    $docLibrary.Update()
    else
    write-host "No content type exists with the name" $lookForRemoveCT "on list" $docLibrary.Title
    I am getting error in delete now. Error is "Exception calling "Delete" with "1" argument(s): "Specified argument was out of the range of valid values.
    Parameter name: id"
    Thanks

  • Workflow attached to content type shows the status as 'Starting'

    Hi,
    I have developed a workflow to distribute documents from Drop Off library to different SharePoint libraries based on the content type that the document uploaded to.
    The drop off library has been configured incoming mail settings hence the documents would be on boarded to drop off library through e-mails. In this scenario, my workflow should be triggered when the document is on boarded through email.
    Another scenario, the user can upload the document to different content type manually and updates the respective meta data values. This scenario, my workflow should be triggered when the item updated.
    So, I have configured my workflow should run on the content types and trigger when item is created through e-mail and item is updated by manual.
    The document on boarded through e-mails are working fine as soon as the item is created.
    Issue:
    The workflow associated on a content type which needs to be triggered on item created is triggering as soon as the user uploads a document manually and shows the status as 'Starting'.
    The workflow associated on a content type which needs to be triggered on item modified is triggering as soon as the user updating meta data values after document is uploaded. Hence, throwing an error
    'cannot open a file from drop off' library exception when I try to read file using C# code as file stream bytes.
    Configuration:
    1. The content types are having mandatory fields which has a default values set.
    2. The document version settings are set as check out the document when editing the properties.
    Please help me to resolve this bug and let me know if you need more details.
    Also, let me know how can we cancel the workflow if it is in 'starting' mode.
    The workflow should run the document is onboardedwhen an item is created and

    Hi,
    According to your description, my understanding is that you want to get data from content type in JSlink.
    I suggest you can get the content type data in JSLink using JavaScript Client Object Model.
    Here are some derailed code demos for your reference:
    http://sharepoint.aspcode.net/view/635399286724222582163436/sharepoint-how-to-get-field-value-using-jsom-jslink-without-async-call
    http://sharepoint.stackexchange.com/questions/93777/how-to-get-contenttype-name-in-clientsidejavascript-jquery-csom-etc-in-editf
    Best Regards
    Zhengyu Guo
    TechNet Community Support

  • Invalid content type for SOAP: TEXT/HTML on Reciever SOAP

    HI All,
    I have a reciever SOAP channel setup to send a message and its attachments to a supplier. The recieving application is as follows:
    "It just receives the stream or contentStream and print out the content. It's just a test to see what you sent to us. It processes all http/https messages."
    If I leave the SOAP Envelope on I get the content type error in the header. If I turn the Enveloper off, I get a successful post. They are try to trap what I send to build a SOAP processor, so they want the SOAP envelope. What could be causing this?
    Kind Regards,
    Chris

    Hi Richard,
    The web service address that we must type in target URL of receiver soap adapter is the address to the WSDL. To be sure types this address in your browser and you must see a WSDL code of the webservice that you want invoke.
    The reason that you are getting “Delivery Exception: invalid content type for SOAP:TEXT/HTML.” is because you are trying to invoke a web service with wrong address.
    So, when SOAP receiver adapter try to put the message on the target side, it can’t and automatically receives an HTTP acknowledge in HTML format. As SOAP adapter doesn’t understand HTML code only XML code, it can’t recognize what kind of error is and generates an exception indicating that the content type is invalid.
    Delivery Exception: invalid content type for SOAP:TEXT/HTML is equal to any HTTP code, I have almost sure that HTTP code is a 404 Not Found, but you can’t see it...
    Post the URL here for I can check
    Cheers,
    Ricardo.

  • Content type of .key files

    Dear team ,
    please tell me the "contenttype" of the .pages file format....
    example: .doc....is having the content type as "application/ms-word"
    similarly can u tell me content type of .pages
    Regards,
    spradeepkumar

    hi balusC thanks, it works very well.
    your site http://balusc.xs4all.nl/srv/dev-jep-pdf.html helped me a lot.
    But one point. There is another method : URLConnection.guessContentTypeFromStream(InputStream)but it don't work and i receive as result a null.
    Is there another classes/methods which helps getting the content type of a file? not necessarily from sun. thanks
    bye

  • Content type attribute

    how do i add attribute to a MimeMessage object's content-type?
    when i create a MimeMessage I always get a content-type which looks similar below,
    Content-Type: multipart/related;
         boundary="----=_Part_1_2704014.1032764882171"
    now i want to add a "type=application/smil" attribute like below
    Content-Type: multipart/related;
         boundary="----=_Part_1_2704014.1032764882171";type=application/smil
    i cant find a MimeMessage or Multipart function that enables me to add an attribute to the content-type? what's the work around here??
    thanks!

    Your question:
    now i want to add a "type=application/smil" attribute like below
    Content-Type: multipart/related;
    boundary="----=_Part_1_2704014.1032764882171";type=application/smil
    i cant find a MimeMessage or Multipart function that enables me to add an attribute to the content-type? what's the work around here??
    thanks!
    Did you ever find a solution to this?
    thanks, brian

  • Cannot get rid of default field in a custom content type

    hi guys,
    I have custom content type based on Document Set in a List based on Document Library. I created both using XML declaration in SP solution.
    I have all fields in my content type which I declared, except to defult fields: 'Name' and 'Description'. I need to hide both of them. After I set Inherits="FALSE" in ContentType section in Elements.xml in ContentType description the field
    'Description' goes away. But the field 'Name' marked as required and stays.
    I've also tried to add RemoveFieldRef parameter to the same Elements file, but the field persists. I assume it comes from list definition, not content type. But I cannot figure out how to get this field out from list definition.
    Do I miss something?

    I am assuming that content type's elements.xml file is looking like this 
    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <!-- Parent ContentType: Document Set (0x0120D520) -->
      <ContentType ID="0x0120D520008d2ff418027e4c31b54d155b98596748"
    Overwrite="True"
    Name="Custom Dossier"
    Group="Custom group"
    Description="Custom dossier"
    Inherits="True"
    Version="0">
        <FieldRefs>
                <FieldRef
    ID="{8D6C094C-3E1F-41f4-BEE3-25B27EE09702}"
    Name="Dossier_Nummer"
    DisplayName="Dossiernummer"
    Required="True" 
    />
        </FieldRefs>
        <XmlDocuments>
          <XmlDocument NamespaceURI="http://schemas.microsoft.com/office/documentsets/allowedcontenttypes">
            <act:AllowedContentTypes
    xmlns:act="http://schemas.microsoft.com/office/documentsets/allowedcontenttypes"
    LastModified="05/31/2012 08:46:56">
              <AllowedContentType
    id="0x0101"
    />
              <AllowedContentType
    id="0x0101000490d50c50624b6ca21c637ef39cd89b"
    />
            </act:AllowedContentTypes>
          </XmlDocument>
        </XmlDocuments>
      </ContentType>
    </Elements>
    In the FieldRef  section ,we have  <FieldRef
    ID="{8D6C094C-3E1F-41f4-BEE3-25B27EE09702}"
    Name="Dossier_Nummer"
    DisplayName="Dossiernummer"
    Required="True" 
    />  this field is there.
    Try to add ShowInNewForm="TRUE" ShowInEditForm="FALSE" those attributes.
    or    Hidden="FALSE" 
    Sorry for the bad English. Could you paste your code.So that we can assist u.

  • In HTTP to SOAP scenario. Error i get is "Invalid content type for SOAP"

    Hi,
    In HTTP to SOAP(synch) scenario. Error i get is <b>"Invalid content type for SOAP"</b>
    When pass my data in the HTTP client, I get the following Error.
    What may be the cause,How to reslove it.
    Response am getting is below............................
    Result:  
    <SAP:Error><SAP:Category>XIAdapterFramework</SAP:Category><SAP:Code>MESSAGE.GENERAL</SAP:Code><SAP:AdditionalText>com.sap.aii.af.ra.ms.api.DeliveryException: invalid content type for SOAP: TEXT/PLAIN</SAP:AdditionalText></SAP:Error>

    hi ,
    Just refer following 2 links
    Re: Invalid content type for SOAP
    Re: invalid content type for SOAP: TEXT/HTML
    Regards,
    AshwinM
    Reward If helpful

  • Get original URL for Link to a Document content type

    Hello,
    I'm having a SharePoint doc library with ItemAdded event receiver attached to it and "Link to a Document" content type enabled. My general question is:
    How to get URL that the link points to?
    I'll show you how I'm trying to achieve that:
    SPWeb parentWeb = properties.Web;
    if (properties.ListItem.ContentType.Name == LinkContentTypeName)
    object urlFieldValue = properties.AfterProperties["URL"];
    if (urlFieldValue != null && urlFieldValue.ToString() != String.Empty)
    // continue
    But I always get null so I can't even get inside IF statement. I've tried to install ItemAdded event receiver as synchronous, but it didn't make a difference. I'd appreciate any ideas.
    Regards
    Tomasz

    This is not very convenient solution, because ItemUpdated can be executed more than once. However this certainly will work, so I'll accept this as a workaround. Actually I've found another one. I'm parsing link aspx file and I'm getting the URL
    from mso:URL tag:
    <%@ Assembly Name='Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' %><%@ Register TagPrefix='SharePoint' Namespace='Microsoft.SharePoint.WebControls' Assembly='Microsoft.SharePoint' %><%@ Import Namespace='System.IO' %><%@ Import Namespace='Microsoft.SharePoint' %><%@ Import Namespace='Microsoft.SharePoint.Utilities' %><%@ Import Namespace='Microsoft.SharePoint.WebControls' %><html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"><Head> <META Name='progid' Content='SharePoint.Link'><!--[if gte mso 9]><SharePoint:CTFieldRefs runat=server Prefix="mso:" FieldList="FileLeafRef,URL,_x0043_C1,KitId,ItemKey,Suffix_x0020_Code"><xml><mso:CustomDocumentProperties><mso:URL msdt:dt="string">http://serverUrl/sites/arrangement1/Shared Drawings/test, test</mso:URL><mso:ContentType msdt:dt="string">Link to a Document</mso:ContentType><mso:File_x0020_Title msdt:dt="string">Winding A Assembled</mso:File_x0020_Title>
    <mso:Revision_x0020_Number msdt:dt="string">-</mso:Revision_x0020_Number>
    <mso:Page_x0020_Size msdt:dt="string">A2</mso:Page_x0020_Size>
    <mso:ContentTypeId msdt:dt="string">0x01010A0082704B66E8B222478AF2E379D8A2FFB9</mso:ContentTypeId>
    <mso:ItemKey msdt:dt="string">1</mso:ItemKey>
    </mso:CustomDocumentProperties></xml></SharePoint:CTFieldRefs><![endif]--></head><body><form id='Form1' runat='server'><SharePoint:UrlRedirector id='Redirector1' runat='server' /></form></body></html>
    Regards
    Tomasz

Maybe you are looking for