SharePoint REST API for Fetching custom Metadata Columns - rest

I am Developing a plugin that exports Documents to SharePoint Repository after processing them. Along with the document, I need to send values for Custom Metadata columns defined in SharePoint.
I have figured out how to send across Files and Metadata to a specified location.
Problem: Initially, I do not know what custom metadata columns are available in the given folder.
Could someone shed light on any REST webservice that can fetch the available Metadata Columns for a given location in the repository.
Note: I am using pure Java for REST Requests using Apache HTTP Client.

The REST url for retrieving the custom fields in a list is:
_api/web/lists/GetByTitle('Custom List')/fields
I don't know much about parsing JSON in java but this will give you a list of all the columns and extensive details about them. I displayed some of the data returned below.
DefaultValue : null
Description : ""
EnforceUniqueValues : false
Id : "fa564e0f-0c70-4ab9-b863-0177e6ddd123"
Indexed : false
InternalName : "Title"
ReadOnlyField : false
Required : false
StaticName : "Title"
Title : "Title"
FieldTypeKind : 2
TypeAsString : "Text"
TypeDisplayName : "Single line of text"
If you need to get the available columns of a specific folder, and not a library:
_api/web/getfolderbyserverrelativeurl('/Shared%20Documents/Folder')/ListItemAllFields

SharePoint 2013 has a REST API endpoint that could retrieve and filter Metadata columns if you obtain the information through a POST request using CAML. If your requests were made from SharePoint itself, you would use the masterpage's RequestDigest, but since you are doing it remotely, you would have to get this parameter by querying /_api/contextinfo and obtaining the FormDigestValue. Here is an article on it:
http://www.cleverworkarounds.com/2013/09/23/how-to-filter-on-a-managed-metadata-column-via-rest-in-sharepoint-2013/
Also, you must enable CORS on your SharePoint data repository.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>

Related

using azure data factory to retrieve blobs urls from a container

I'm using Azure, I have some blobs in a container, what I'm looking for is to copy the urls of these blobs in a json file using azure data factory or data flow.
heres as example of a url :
the expected result is :
[[{'ur':'urltObLOB1'},{'ur':'urltObLOB2'},{'ur':'urltObLOB3'},.....]
is there a way to achieve that using azure data factory or data flow please ?
I could not find an activity or out of the box method to achieve the ask. However if you look at the REST api
The List Blobs operation returns a list of the blobs under the specified container.
In version 2013-08-15 and newer, the EnumerationResults element
contains a ServiceEndpoint attribute specifying the blob endpoint, and
a ContainerName field specifying the name of the container. In
previous versions these two attributes were combined together in the
ContainerName field. Also in version 2013-08-15 and newer, the Url
element under Blob has been removed.
Checkout MS DOC List blobs and snapshots
An example shows the result of a listing operation that returns blobs and snapshots in a container named mycontainer.
The request URI is as follows:
GET https://myaccount.blob.core.windows.net/mycontainer?restype=container&comp=list&include=snapshots&include=metadata
Sample XML response contains a block for each blob in the container.
<Blob>
<Name>blob3.txt</Name>
<Url>https://myaccount.blob.core.windows.net/mycontainer/blob3.txt</Url>
<Properties>
<Last-Modified>Wed, 09 Sep 2009 09:20:03 GMT</Last-Modified>
<Etag>0x8CBFF45D911FADF</Etag>
<Content-Length>16384</Content-Length>
<Content-Type>image/jpeg</Content-Type>
<Content-Encoding />
<Content-Language />
<Content-MD5 />
<Cache-Control />
<x-ms-blob-sequence-number>3</x-ms-blob-sequence-number>
<BlobType>PageBlob</BlobType>
<LeaseStatus>locked</LeaseStatus>
</Properties>
<Metadata>
<Color>yellow</Color>
<BlobNumber>03</BlobNumber>
<SomeMetadataName>SomeMetadataValue</SomeMetadataName>
</Metadata>
</Blob>
You can find the blob URL between <Url> </Url>
Next you can parse the XML output to store the url values in an array variable in the pipeline.

Extract only data (without response element) using MarkLogic search API with REST

When making REST endpoint call to MarkLogic, is there an option to get only the data in the response without the additional metadata?
I am trying to use to make such connections using tools like Tableau, Qlik, Denodo etc
Options I use in the POST body on the URL: http://localhost:8000/v1/search
<search xmlns="http://marklogic.com/appservices/search">
<options>
<extract-document-data selected="all"></extract-document-data>
<transform-results apply="raw" />
</options>
</search>
Result I get:
<search:response snippet-format="raw" total="150" start="1" page-length="10" selected="all" xmlns:search="http://marklogic.com/appservices/search">
<search:result index="1" uri="/doc/21_doc.xml" path="fn:doc("/doc/21_doc.xml")" score="0" confidence="0" fitness="0" href="/v1/documents?uri=%2Fdoc%2F21_doc.xml" mimetype="application/xml" format="xml">
<root>
<col1>data1</col1>
<col2>data1</col2>
<col3>data1</col3>
</root>
<search:extracted kind="element">
<root>
<col1>data1</col1>
<col2>data1</col2>
<col3>data1</col3>
</root>
</search:extracted>
</search:result>
<search:metrics>
<search:query-resolution-time>PT0.0005236S</search:query-resolution-time>
<search:snippet-resolution-time>PT0.0001001S</search:snippet-resolution-time>
<search:extract-resolution-time>PT0.0003971S</search:extract-resolution-time>
<search:total-time>PT0.0021503S</search:total-time>
</search:metrics>
</search:response>
Expected:
<search:extracted kind="element">
<root>
<col1>data1</col1>
<col2>data1</col2>
<col3>data1</col3>
</root>
</search:extracted>
Also, why am I getting data in both extracted and result elements?
Both snippeting and data extraction provide access to content. Use either, or use them for different purposes. If you only like to get extracted data, then use:
<transform-results apply="empty-snippet" />
HTH!
If you want the original documents, specify an Accept header of multipart-mixed and specify only the content value for the a category URI parameter.
See: https://docs.marklogic.com/REST/POST/v1/search
and https://docs.marklogic.com/guide/rest-dev/bulk#id_65903
As an alternative, you may find it easier to provide rows to Business Intelligence Tools by creating TDE indexes and paging over an Optic query with the /v1/rows endpoint.
See: https://docs.marklogic.com/guide/rest-dev/search#id_34628
and https://docs.marklogic.com/REST/POST/v1/rows
Hoping that helps,

How to get purchase order documents from tradeShift API?

I am trying to get the trade shift purchase order using their API.
FYI, While I am making an API request,
I am using OAuth1.
I am using endpoint
https://api-sandbox.tradeshift.com/tradeshift/rest/external/documents?limit=5
In the header, When I set Accept as application/JSON, I am getting a response like
{
"itemsPerPage": 5,
"itemCount": 2,
"indexing": false,
"numPages": 1,
"pageId": 0,
"Document": []
}
But If I add nothing in the Header, I am getting an XML response.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ts:DocumentList xmlns:cec="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:ts="http://tradeshift.com/api/public/1.0" xmlns:ns6="http://tradeshift.com/api/1.0" xmlns:ns7="http://tradeshift.com/api/2.0" xmlns:ns8="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:ns9="urn:oasis:names:specification:ubl:schema:xsd:Quotation-2" xmlns:ns10="urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2" xmlns:ns11="urn:oasis:names:specification:ubl:schema:xsd:Order-2" xmlns:ns12="urn:oasis:names:specification:ubl:schema:xsd:OrderChange-2" xmlns:ns13="urn:oasis:names:specification:ubl:schema:xsd:ApplicationResponse-2" xmlns:ns14="urn:oasis:names:specification:ubl:schema:xsd:Reminder-2" xmlns:ns15="urn:oasis:names:specification:ubl:schema:xsd:RemittanceAdvice-2" xmlns:ns16="urn:oasis:names:specification:ubl:schema:xsd:ReceiptAdvice-2" xmlns:ns17="urn:oasis:names:specification:ubl:schema:xsd:Catalogue-2" xmlns:ns18="https://tradeshift.com/documents/ubl/xsd/Requisition-2" xmlns:ns19="urn:oasis:names:specification:ubl:schema:xsd:OrderResponse-2" xmlns:ns20="urn:oasis:names:specification:ubl:schema:xsd:RequestForQuotation-2" xmlns:ns21="urn:oasis:names:specification:ubl:schema:xsd:OrderResponseSimple-2" xmlns:ns22="urn:oasis:names:specification:ubl:schema:xsd:OrderCancellation-2" xmlns:ns23="urn:oasis:names:specification:ubl:schema:xsd:DespatchAdvice-2" indexing="false" numPages="1" pageId="0" itemsPerPage="5" itemCount="2"/>
I am not quite sure if the document is already there as UBL format.
Can you please ensure, if the document is already there as UBL.
If document is there, then How can I parse the document?
And if the document is not there, how can I get the documents?
The document is not there, that both responses are the same just the format is different.
In order to get the Documents that you receive in your Tradeshift account you should follow the below steps:
get the list with all the documents available in your account using the below API:
GET https://api-sandbox.tradeshift.com/tradeshift/rest/external/documents?type=order Content-Type=application/json Accept=application/json Authorisation=oauth1
As response, you will have a JSON with all the orders in your account and the details you will need to retrieve the UBL file of the order.
From the JSON resulted in point 1 using the DocumentId of the order you want to get make the below call
GET https://api-sandbox.tradeshift.com/tradeshift/rest/external/documents/{DocumentUUID} Content-Type=application/json Accept=application/xml Authorisation=oauth1
Once you get a file in order to get it marked as processed you can also tag the document using the below API call:
PUT https://api.tradeshift.com/tradeshift/rest/external/documents/{DocumentId}/tags/{your-tag}
At the first call, you can then add more parameters like withouttag in order to filter out the documents you have tagged already, like in the below call:
`GET https://api-sandbox.tradeshift.com/tradeshift/rest/external/documents?type=order&withouttag={your-tag}`

get the Magento SOAP XML request parameters

I have crated a magento custom SOAP V2 Module,i have a xml request as follows.
from the firebug
----------------
endpoint :http://202.129.197.46:4141/magento/vmagento9/inventory.php
operationName :getFilterValues
requestXml :<GetFilterValuesRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.promostandards
.org/WSDL/InventoryService/1.0.0/">
<wsVersion>Token1</wsVersion>
<id>tvijay12312</id>
<password>Token1</password>
<productID>Token1</productID>
<productIDtype>Token1</productIDtype>
</GetFilterValuesRequest>
version : 1.2.1
webServiceName : Inventory
from this i want the id,password,productId and productIDtype.
kindly share your idea to get this request data and pass to the login and mycustom api methods

silverstripe RestfulServer Module - get related records with all attributes

Using the Restful Server Module I do this operation:
GET /api/v1/(ClassName)?(Field)=(Val)&(Field)=(Val) - searches for matching database records
The api should get the urls of all images related to a certain product like this:
http://domain.com/api/v1/Product?ArticleID=myID
unfortunately the returned XML does not show the full information of the ProductImages. just the attributes href and id.
here the xml:
<?xml version="1.0" encoding="UTF-8"?>
<ArrayList totalSize="1">
<Product href="http://domain.com/api/v1/Product/9.xml">
<ArticleID>myID</ArticleID>
<ID>9</ID>
<ProductImages linktype="has_many" href="http://domain.com/api/v1/Product/9/ProductImages.xml">
<ProductImage href="http://domain.com/api/v1/ProductImage/265.xml" id="265"/>
<ProductImage href="http://domain.com/api/v1/ProductImage/268.xml" id="268"/>
<ProductImage href="http://domain.com/api/v1/ProductImage/271.xml" id="271"/>
</ProductImages>
</Product>
</ArrayList>
ProductImage has much more attributes actually which are not displayed in the xml. How to make them visible? I can see all ProductImage Attributes when doing e.g. this:
http://domain.com/api/v1/Product/9/ProductImages
I use curl to load the urls.
In the worst case I think I have to take the ProductImage urls from the XML (e.g. http://domain.com/api/v1/ProductImage/271.xml) and do multiple calls.
many thx for any help,
florian
You need to increase the relationDepth inside RestfulServer. You can do that by passing in the relationdepth query string parameter.
As an aside, the reason it works like this is to keep the load low on the server by not having to instantiate all the image objects. It also means bandwidth is slightly lower too.