SharePoint Onlinie - Create Drive using graph service client - sharepoint

I am working on one project where I've to create a drive (document library) on SharePoint in not exists.
Using following code:
var newRRRDrive = new Drive
{
Name = "RRRR-Prod1",
Description = "Holds RRRR files",
AdditionalData = new Dictionary<string, object>()
{
{"#microsoft.graph.conflictBehavior","rename"}
}
};
var newDrive = await graphClient
.Sites[site.Id]
.Drives
.Request()
.AddAsync(newRRRDrive);
But this is throwing exception that the request is invalid. I don't know what I doing wrong here.. Any suggestions?
Code: invalidRequest
Message: Invalid request
Inner error:
AdditionalData:
date: 2021-05-30T20:57:40
request-id: ec6ddddddddddddddd0f72d91c8e
client-request-id: ec6ddddddddddddddddddddddddddddddddd
ClientRequestId: ec6dedddddddddddddddddddddddddddddddddddddddddddd
Adding image after implementing soln by Michael
enter image description here

To create a new document library, you can perform the same call as mentioned in the create list instead of using the genericList template value. Use the documentLibrary value.
POST /sites/{site-id}/lists
Content-Type: application/json
{
"displayName": "YourLibraryName",
"list": {
"template": "documentLibrary"
}
}
C# code
var list = new List
{
DisplayName = "Books",
ListInfo = new ListInfo
{
Template = "documentLibrary"
}
};
await graphClient.Sites["{site-id}"].Lists
.Request()
.AddAsync(list);

Related

Netsuite restlet: src property must be a valid json object

I'm attempting to write a RESTlet script to pull over some work order data to another web application (Tulip), but when I attempt to run the script, I receive the following error output:
"src property must be a valid json object"
My get request does have the "Content-Type: application/json" header.
Here is the script I'm attempting to run for reference (the script is very basic at the moment as I just try to figure this all out):
function getWOSoftLock(){
var WOColumns = new Array();
WOColumns[0] = new nlobjSearchColumn('tranid');
WOColumns[1] = new nlobjSearchColumn('status');
var filter = new nlobjSearchFilter(
'status',
null,
'is',
'Released',
null
);
var dataoutput = nlapiSearchRecord(
'workorder',
null,
filter,
WOColumns
);
return dataoutput
}
Any help would be much appreciated as I'm new at this. If I do not include the Content-Type: application/json header, I receive "Invalid data format. You should return text."
The SS1 search results were funny beasts and did not used to serialize properly.
You should do something like:
function getWOSoftLock() {
var dataoutput = nlapiSearchRecord(
'workorder',
null,
new nlobjSearchFilter('status', null, 'is', 'Released'),
[
new nlobjSearchColumn('tranid'),
new nlobjSearchColumn('status')
]
);
if(!dataoutpout) {
nlapiLogExecution('AUDIT', 'No released work orders');
return [];
}
return dataoutput.map(function(res){
return {
tranid:res.getValue('tranid'),
status:res.getValue('status')
};
});
}

docusignapi | place to sign are lost when updating an envelope

my UI when create and wh
My code to update:
var recipients = envelopesApi.ListRecipients(accountId, envelopeId, new EnvelopesApi.ListRecipientsOptions { includeTabs = true.ToString() });
foreach (var doc in documents)
{
var retornoDelete = envelopesApi.DeleteDocuments(accountId, envelopeId, new EnvelopeDefinition { Documents = new List<Document> { doc } });
}
var resultUpdateDocuments = envelopesApi.UpdateDocuments(accountId, envelopeId, new EnvelopeDefinition { Documents = envelope.Documents, Recipients = recipients });
var resultUpdateRecipients = envelopesApi.UpdateRecipients(accountId, envelopeId, recipients, new EnvelopesApi.UpdateRecipientsOptions { resendEnvelope = "true" });
I have try this link bellow, but not work for me:
DocuSign: Signer Tabs are lost when updating an envelope
Im not sure what you are trying to do in this code, but you are both updating the recipient and the document. It make a lot more sense to create a new envelope at this point, instead of 3 API calls - you can make just one.
The reason you don't see the tab (SignIn) is because you are updating the recipients and documents again and that won't by itself update the tabs. You need to make yet another API call for this (https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/envelopedocumenttabs/update/)
I recommend you reconsider this flow to just create a new envelope with all the information in one call. But if you need to do it this way - you'll need another API call.
the Create Tabs work here, i guess this will sufficient
foreach (var item in recipients.Signers)
{
try
{
var tabsRecipient = envelope.Recipients.Signers.Where(x => x.Email == item.Email).Select(x => x.Tabs).First();
var resultUpdateTabs = envelopesApi.CreateTabs(accountId, envelopeId, item.RecipientId, tabsRecipient);
}
catch (Exception ex)
{
// this recipient have a constraint
}
}

Basic authentication for Swagger-UI not working correctly

I have setup Swagger within my ASP.NET project using NSwag which works fine but I am attempting to add support for authentication.
My authentication model is a simple username/password that uses OAuth using ApplicationOAuthProvider
The URL I use to login is as below
/token
With the POST parameters:
grant_type=password&username=${username}&password=${password}
Now my swagger setup [in Global.asax] is
app.UseSwaggerUi(typeof(Global).Assembly, new SwaggerUiSettings
{
MiddlewareBasePath = "/swagger",
OAuth2Client = new OAuth2ClientSettings
{
ClientId = "my_auth_id",
//ClientSecret = "bar",
AppName = "my",
//Realm = "my_realm",
//AdditionalQueryStringParameters = { { "foo", "bar" } }
},
DocumentProcessors = {
new SecurityDefinitionAppender("oauth2", new SwaggerSecurityScheme
{
Type = SwaggerSecuritySchemeType.Basic,
Description = "Description is set htere",
Flow = SwaggerOAuth2Flow.Password,
AuthorizationUrl = "https://localhost:28866/token?",
TokenUrl = "https://localhost:28866/token",
In = SwaggerSecurityApiKeyLocation.Query
//Scopes = new Dictionary<string,string>
//{
// //{ "read", "Read access to protected resources" },
// { "write", "Write access to protected resources" }
//}
})
},
OperationProcessors =
{
new OperationSecurityScopeProcessor("oauth2")
}
});
I know its a bit messy but I was literally trying every option I could to make it work.
So this actually gives me the Authorize button and a Username and Password field. But when I click login it refreshes the swagger.json but doesnt actually attempt to log in anywhere?

Sharing login session between Acumatica Screen based API and the Contract based API

How to share login session between Acumatica Screen based API and the Contract based API?
Sharing session data between Contract-Based and Screen-Based API is supported in 5.30.1672 build onwards.
In below code snippet, we are logging in via Contract Based API, retrieving session cookie and using it in Screen Based API.
string sharedCookie;
var soapClient = new DefaultSoapClient();
using (new OperationContextScope(soapClient.InnerChannel))
{
soapClient.Login("admin", "123", null, null, null);
var responseMessageProperty = (HttpResponseMessageProperty)
OperationContext.Current.IncomingMessageProperties[HttpResponseMessageProperty.Name];
sharedCookie = responseMessageProperty.Headers.Get("Set-Cookie");
}
try
{
apitest.Screen context = new apitest.Screen();
context.CookieContainer = new System.Net.CookieContainer();
context.Url = "http://localhost/AcumaticaCBWS/Soap/APITEST.asmx";
context.CookieContainer.SetCookies(new Uri(context.Url), sharedCookie);
SO301000Content salesOrdersSchema = context.SO301000GetSchema();
var commands = new Command[]
{
new Value
{
LinkedCommand = salesOrdersSchema.OrderSummary.OrderType,
Value = "SO"
},
salesOrdersSchema.OrderSummary.ServiceCommands.EveryOrderNbr,
salesOrdersSchema.OrderSummary.OrderType,
salesOrdersSchema.OrderSummary.OrderNbr,
salesOrdersSchema.OrderSummary.Description
};
var orders = context.SO301000Export(commands, null, 10, false, false);
}
finally
{
soapClient.Logout();
}
}

Sharepoint 2013: Inserting image on page javascript csom

I create a new page with javascript csom. I am able to give it a title, byline, content etc., but it won't accept an image reference. It doesn't give me any error messages, nor reaching my error function, but I'm obviously missing something here as the new page does not have any images attached.
Any ideas on how to do this?
Here is my code:
var pageInfo = new SP.Publishing.PublishingPageInformation();
var newPage = pubWeb.addPublishingPage(pageInfo);
context.load(newPage);
context.executeQueryAsync(function () {
var listItem = newPage.get_listItem();
context.load(listItem);
context.executeQueryAsync(function () {
var title = $('#head').val();
listItem.set_item('Title', title);
listItem.set_item('PublishingPageImage', { "Url": "/sites/intranett/PublishingImages/ExampleImage.png", "Description": "testing" });
listItem.update();
context.executeQueryAsync(function () { }, onFailedCallback);
}, onFailedCallback);
}, onFailedCallback);
I needed to include the html image tag when setting the PublishingPageImage property.
listItem.set_item('PublishingPageImage', "<img alt='image' src='/sites/intranett/PublishingImages/ExampleImage'>");

Resources