Coder Social home page Coder Social logo

smartsheet-csharp-sdk's Introduction

Smartsheet SDK for C# Build Status Coverage Status NuGet

This is a C# SDK to simplify connecting to the Smartsheet API from .NET applications.

Notice

This repo has moved to the Smartsheet Organization on GitHub and can be accessed here.

NOTE ON 2.93.0 RELEASE

While investigating issue #113, the API/SDK team discovered that Newtonsoft Json.NET, by default, deserializes JSON strings that "look like" dates into C# DateTime objects. You can read the discussion here. Smartsheet believes this to be undesirable behavior (since JSON doesn't have a date construct, all JSON strings should be handled as C# strings), therefore, this release changes the global behavior to disable this feature of Json.NET. If you have implementations that rely on the previous behavior, there is an opt-out feature that you can use. An example of the opt-out code is here:

SmartsheetClient smartsheet = new SmartsheetBuilder()
    .SetAccessToken("JKlMNOpQ12RStUVwxYZAbcde3F5g6hijklM789")       // TODO: Set your API access in environment variable SMARTSHEET_ACCESS_TOKEN or else here
    .SetHttpClient(new RetryHttpClient())
    .SetDateTimeFixOptOut(true)
    .Build();

System Requirements

The SDK supports C# version 4.0 or later and targets .NET Framework version 4.5.2 or later or .NET Standard 2.0 or later. In addition, we support any .NET language compatible with those platform versions.

Installation

The SDK can be installed by using NuGet or by compiling from source. These two alternatives are outlined below.

Install with NuGet

If unfamiliar with NuGet, please take a look at the NuGet documentation.

To install the SDK in Visual Studio, right click the References for the project and select Manage NuGet Packages.

Select the Browse or Online tab (depending upon the version of Visual Studio) then type smartsheet in the search box. Select smartsheet-csharp-sdk in the search results and click the Install button.

After clicking Install, you will be asked to accept the License (Apache). Then it will install the Smartsheet SDK and the dependencies (RestSharp, Newtonsoft.Json, and NLog) by adding these libraries to the References section of the project.

You can also use the following command in the Package Manager Console to install the SDK:

Install-Package smartsheet-csharp-sdk

Compile From Source

You can download and compile the source code for the SDK from Github. Use git to fetch it and use Visual Studio 2017 or later to build it.

git clone https://github.com/smartsheet-platform/smartsheet-csharp-sdk.git

In Visual Studio 2017 you can open the entire solution with the file smartsheet-csharp-sdk-v2.sln, or open the specific project smartsheet-csharp-sdk-v2.csproj.

Example Usage

To call the API, you will need an access token, which looks something like this example: ll352u9jujauoqz4gstvsae05. You can find the access token in the UI at Account > Personal Settings > API Access.

The following is a brief sample that shows you how to:

  • Initialize the client
  • List all sheets
  • Load one sheet
using Smartsheet.Api;
using Smartsheet.Api.Models;

static void Sample()
{
    // Initialize client
    SmartsheetClient smartsheet = new SmartsheetBuilder()
        // TODO: Set your API access in environment variable SMARTSHEET_ACCESS_TOKEN or else here
        // .SetAccessToken("JKlMNOpQ12RStUVwxYZAbcde3F5g6hijklM789")
        .Build();

    // List all sheets
    PaginatedResult<Sheet> sheets = smartsheet.SheetResources.ListSheets(
        null,               // IEnumerable<SheetInclusion> includes
        null,               // PaginationParameters
        null                // Nullable<DateTime> modifiedSince = null
    );
    Console.WriteLine("Found " + sheets.TotalCount + " sheets");

    long sheetId = (long) sheets.Data[0].Id;                // Default to first sheet

    // sheetId = 567034672138842;                         // TODO: Uncomment if you wish to read a specific sheet

    Console.WriteLine("Loading sheet id: " + sheetId);

    // Load the entire sheet
    var sheet = smartsheet.SheetResources.GetSheet(
        5670346721388420,           // long sheetId
        null,                       // IEnumerable<SheetLevelInclusion> includes
        null,                       // IEnumerable<SheetLevelExclusion> excludes
        null,                       // IEnumerable<long> rowIds
        null,                       // IEnumerable<int> rowNumbers
        null,                       // IEnumerable<long> columnIds
        null,                       // Nullable<long> pageSize
        null                        // Nullable<long> page
    );
    Console.WriteLine("Loaded " + sheet.Rows.Count + " rows from sheet: " + sheet.Name);
}

A simple, but complete sample application project is here: https://github.com/smartsheet-samples/csharp-read-write-sheet

Advanced Topics

For details about logging, testing, how to use a passthrough option, and how to override HTTP client behavior, see Advanced Topics.

Documentation

The full Smartsheet API documentation is here: https://smartsheet.redoc.ly.

The generated SDK class documentation is here: http://smartsheet-platform.github.io/smartsheet-csharp-sdk/.

Contributing

If you would like to contribute a change to the SDK, please fork a branch and then submit a pull request. More info here.

Version Numbers

Starting from the v2.68.0 release, Smartsheet SDKs will use a new versioning strategy. Since all users are on the Smartsheet API 2.0, the SDK version numbers will start with 2. The 2nd number will be an internal reference number. The 3rd number is for incremental changes.

For example, v2.68.0 means that you are using our 2.0 version of the API, the API is synced internally to a tag of 68, and then if there are numbers after the last decimal, that will indicate a minor change.

Support

If you have any questions or issues with this SDK please post on StackOverflow using the tag "smartsheet-api" or contact us directly at [email protected].

Release Notes

All releases and release notes are available on Github or the NuGet repository.

smartsheet-csharp-sdk's People

Contributors

abryan-smartsheet avatar activescott avatar bogdansireteanu avatar brentaiipllc avatar brettbatie avatar cameronbowie avatar coxito avatar ericspaghetti avatar gpltaylor avatar jtp3xp avatar kbrandl avatar kfansler avatar matsumiyat avatar nerfix avatar orthographic-pedant avatar seweil avatar stollgr avatar thijs4ef avatar timwellswa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

smartsheet-csharp-sdk's Issues

Update RestSharp

I have a project which has a dependency on RestSharp 107.3.0 and when including this project with its dependency on RestSharp 106.2.1 which is very old. Any chance someone has a fork which has successfully updated to the latest (or one of the later) versions of RestSharp??

Include rowsModifiedSince filter

When getting Sheet content using GetSheet method there is no option to include rowsModifiedSince filter.
version: 2.101.0

Are there any plans to include this in a future release?

RestSharp v108 compatibility with SmartSheet 2.126.0

After update to RestSharp v108 from v106.15.0, we are facing following issue while connecting with SmartSheet SDK v2.126.0

'Method not found: 'Void RestSharp.RestClient.set_FollowRedirects(Boolean)'

Seems this property is no longer available in v108 however SmartSheet SDK v2.126.0 is still using old version.

Once we update SmartSheet SDK to newly released v 3.0.0 then its dependent upon .Net6, where as our project is using .NET framework 4.8, Once we add Smart sheet 3.0.0 via Nuget, at run time we are getting exception, "Could not load file or assebly System.Runtime version 6.0.0.0"

Can somebody please suggest what is the alternate or way forward?

Copying workspace timeout

When copying large workspace or worskapce that contains a large logic, the API call timeout :

Object reference not set to an instance of an object. System.NullReferenceException: Object reference not set to an instance of an object.
   at Smartsheet.Api.SmartsheetRestException..ctor(Error error)
   at Smartsheet.Api.Internal.AbstractResources.HandleError(HttpResponse response)
   at Smartsheet.Api.Internal.AbstractResources.CreateResource[S,T](String path, T object)
   at Smartsheet.Api.Internal.WorkspaceResourcesImpl.CopyWorkspace(Int64 workspaceId, ContainerDestination destination, IEnumerable`1 include, IEnumerable`1 skipRemap)

This is mainly caused beacause the query is timing out. I increase the timeout of the RestClient, using my own implementatin of the DefaultHttpClient :

 public class TimeoutHttpClient : DefaultHttpClient
    {
        public TimeoutHttpClient() : base(new RestSharp.RestClient() { Timeout = 1_000_000, ReadWriteTimeout = 1_000_000 }, new JsonNetSerializer())
        {
        }
...

And so the error isn't now as part of the web call settings, but from the smartsheet server that is timing out. Can we gets some clarification why is this happening and any stratgey to handle this ?

MULTI_PICKLIST reporting as TEXT_NUMBER

version 2.101 ... sheet with a column configured as MULTI_PICKLIST on SmartSheet shows as having Type property of ColumnType.TEXT_NUMBER (when reading client.Columns[n].Type ). But when adding a row with a cell for this column, the API throws an exception suggesting it has to use ObjectValue and not Value for parameters.

On some recurring calls, Deserialize errors happens

On some recurring calls, Deserialize errors happens. Any clue why it happen and when the issue will be solved ?

Unexpected character encountered while parsing value: <. Path '', line 0, position 0. Smartsheet.Api.SmartsheetException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
 ---> Smartsheet.Api.Internal.Json.JsonSerializationException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
 ---> Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
   at Newtonsoft.Json.JsonTextReader.ParseValue()
   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize[T](JsonReader reader)
   at Smartsheet.Api.Internal.Json.JsonNetSerializer.deserialize[T](StreamReader inputStream)
   --- End of inner exception stack trace ---
   at Smartsheet.Api.Internal.Json.JsonNetSerializer.deserialize[T](StreamReader inputStream)
   at Smartsheet.Api.Internal.AbstractResources.HandleError(HttpResponse response)
   --- End of inner exception stack trace ---
   at Smartsheet.Api.Internal.AbstractResources.HandleError(HttpResponse response)
   at Smartsheet.Api.Internal.AbstractResources.ListResourcesWithWrapper[T](String path)
   at Smartsheet.Api.Internal.UserResourcesImpl.ListUsers(IEnumerable`1 emails, IEnumerable`1 includes, PaginationParameters paging)
   at Smartsheet.Api.Internal.UserResourcesImpl.ListUsers(IEnumerable`1 emails, PaginationParameters paging)

Or while calling ListColumns :

An unexpected error has occurred. Please contact the Support team at https://help.smartsheet.com/contact for assistance. Smartsheet.Api.InvalidRequestException: An unexpected error has occurred. Please contact the Support team at https://help.smartsheet.com/contact for assistance.
   at Smartsheet.Api.Internal.AbstractResources.HandleError(HttpResponse response)
   at Smartsheet.Api.Internal.AbstractResources.ListResourcesWithWrapper[T](String path)
   at Smartsheet.Api.Internal.SheetColumnResourcesImpl.ListColumns(Int64 sheetId, IEnumerable`1 include, PaginationParameters paging, Nullable`1 level)

Unable to Search Sheet Summary

While searching for sheet summary, I'm getting the following error:

API call

SearchResult results = smartsheet.SearchResources.Search(query)

Exception

Error converting value \"summaryField\" to type 'System.Nullable'1[Smartsheet.Api.Models.SearchObjectType]'. Path 'results[0].objectType', line 1, position 56.

Api support for column formula

The native API supports column formula (read/write), from what I understand, to port to the C# wrapper only one change is required : adding a formula property to the column type:

/// Column formula
/// </summary>
private string formula;

/// <summary>
/// Column formula.
/// </summary>
public string Formula
{
    get { return formula; }
    set { formula = value; }
} 

(see also 476e367)

RowInclusion on C# never returns Includes

When using the C# Call to pull the row it does not return the permalink:

        var rowincludes = new RowInclusion[] { RowInclusion.ROW_PERMALINK,RowInclusion.COLUMNS };
        var rowlink = _client.SheetResources.RowResources.GetRow(sheetid, rowid, rowincludes, new RowExclusion[] { });

.NET Core unhandled exception

I am using .NET Core 2.2. When GetOSFriendlyName() gets called, the following exception is being thrown:

System.TypeInitializationException
  HResult=0x80131534
  Message=The type initializer for 'System.Management.ManagementPath' threw an exception.
  Source=System.Management
  StackTrace:
   at System.Management.ManagementScope._Clone(ManagementScope scope, IdentifierChangedEventHandler handler)
   at System.Management.ManagementObjectSearcher..ctor(ManagementScope scope, ObjectQuery query, EnumerationOptions options)
   at Smartsheet.Api.Internal.Utility.Utility.GetOSFriendlyName() in C:\Users\Pedro\Source\repos\SmartSheetImporter\SmartSheetImporter\Smartsheet\Api\Internal\Util\Util.cs:line 38
   at Smartsheet.Api.Internal.SmartsheetImpl.GenerateUserAgent(String userAgent) in C:\Users\Pedro\Source\repos\SmartSheetImporter\SmartSheetImporter\Smartsheet\Api\Internal\SmartsheetImpl.cs:line 610
   at Smartsheet.Api.Internal.SmartsheetImpl.set_UserAgent(String value) in C:\Users\Pedro\Source\repos\SmartSheetImporter\SmartSheetImporter\Smartsheet\Api\Internal\SmartsheetImpl.cs:line 347
   at Smartsheet.Api.Internal.SmartsheetImpl..ctor(String baseURI, String accessToken, HttpClient httpClient, JsonSerializer jsonSerializer) in C:\Users\Pedro\Source\repos\SmartSheetImporter\SmartSheetImporter\Smartsheet\Api\Internal\SmartsheetImpl.cs:line 269
   at SmartSheetImporter.AppStart.BuildSmartsheetClient() in C:\Users\Pedro\Source\repos\SmartSheetImporter\SmartSheetImporter\AppStart.cs:line 110
   at SmartSheetImporter.AppStart.<>c.<ConfigureServices>b__12_1(IServiceProvider smartSheet) in C:\Users\Pedro\Source\repos\SmartSheetImporter\SmartSheetImporter\AppStart.cs:line 47
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitTransient(TransientCallSite transientCallSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitTransient(TransientCallSite transientCallSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
   at SmartSheetImporter.AppStart.RefreshData() in C:\Users\Pedro\Source\repos\SmartSheetImporter\SmartSheetImporter\AppStart.cs:line 76
   at SmartSheetImporter.AppStart.Main(String[] args) in C:\Users\Pedro\Source\repos\SmartSheetImporter\SmartSheetImporter\AppStart.cs:line 70

Inner Exception 1:
TypeInitializationException: The type initializer for 'System.Management.WmiNetUtilsHelper' threw an exception.

Inner Exception 2:
ArgumentNullException: Value cannot be null.
Parameter name: ptr

it seems there is some logic to attempt to figure out if .Net Core is being used in the following catch:

catch (System.NotImplementedException)
            {
                return ".Net Core-" + System.Environment.OSVersion.VersionString;
            }

I replaced the System.NotImplementedException with a generic exception to make it work.

UNABLE to get Multi-Contact

When using getSheet and a cell is a MULTI_Contact, Object is not DE-serialized, just returns an empty {Smartsheet.Api.Models.ContactObjectValue}

GetOSFriendlyName - Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)

when deployed to Azure (website) the following exception is throw. This is due to a permission denied error where the profile does not have access to this resource.

Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
[UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))]
System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) +0
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode) +10851991
System.Management.ManagementScope.InitializeGuts(Object o) +379
System.Management.ManagementScope.Initialize() +177
System.Management.ManagementObjectSearcher.Initialize() +196
System.Management.ManagementObjectSearcher.Get() +35
Smartsheet.Api.Internal.Utility.Utility.GetOSFriendlyName() +60
Smartsheet.Api.Internal.Http.DefaultHttpClient.buildUserAgent() +168
Smartsheet.Api.Internal.Http.DefaultHttpClient..ctor(RestClient httpClient) +67
Smartsheet.Api.SmartsheetBuilder.Build() +55

Unable to Copy Rules

When using smartsheet.FolderResources.CopyFolder() or smartsheet.SheetResources.CopySheet() there is no way to include the sheet notifications as the FolderCopyInclusion enum does not have the associated rule and ruleRecipients flags. This seems to be possible using HTTP requests as documented here but appears missing from the C# API.

Security Vulnerability in RestSharp dependency

CVE-2021-27293

There is a security vulnerability in the RestSharp dependency of smartsheet-csharp-sdk that is leaving your package vulnerable. It has been patched, so the smartsheet-csharp-sdk package will need to be updated with a patched version. More info is available at the link above.

This package will need to be updated to a patched version of RestSharp.

Proxy Server

Please can you add provision to provide an IWebProxy object for those who have applications within a corporate environment.

Having to create specialised IWebProxy classes and add to the .config file, whist works, is a bit haphazard.

Providing a Property / Constructor param would make things a lot cleaner

Double url escaping for the search api call

The search api sdk action does not work properly.
In the current sdk version a space will turn into %2520, it should be %20. This is happening because the search query is escaped twice.

Escaping for the search call is done in main/Smartsheet/Api/Internal/SearchResourcesImpl.cs and in smartsheet-csharp-sdk/main/Smartsheet/Api/Internal/Util/QueryUtil.cs in the current sdk.

I created a pull request which solves this issue: #116 .

Thanks!

AbstractResources Missing

The file AbstractResources appears to be deleted with no substitute. The code base still replied on this and the project even references this file that no longer exists.

NullReferenceException when getting shares for workspaces

Hi,

When executing this code a NullReferenceException occurs:

var shares = smartsheet.Workspaces().Shares().ListShares((long)w.ID);

where "smartsheet" is a SmartsheetClient instance and w.ID is a workspace ID. I dug in the C# SDK code and discovered this commit (7704c5a) where in WorkspaceResourcesImpl.cs on line 56 and 57 two assignments had been commented out. I put these two assignments back in again, and the NullReferenceException was gone and I got the share information I wanted.

I notice this commit is named "Tabs to spaces & License in Header", so I assume a code change like this in this commit is an oversight?

Best,
Stein J. Gran

More informative error response

I've started getting the error "There was an issue connecting" .. However, there is nothing to indicate the nature of the issue.

Copy workspace inclusion

While copying a workspace, workflows attached to sheets are not copied while using "include=all"

The issue is also reproduced in postman directly :

https://api.smartsheet.com/2.0/workspaces/id/copy?include=All
//body :
{"newName":"Demo_2020-02-25 12:52"}

There was an issue connecting c#

Hi!
I use VS 2019 on my laptop (windows 10 Pro, 1903, x64)

create a new c# console app, add sdk from NuGet

NetFramework = 4.5.2, Nlog+Newtonsoft+RestShart = last versoin

next step

//add in project

using Smartsheet.Api;

using Smartsheet.Api.Internal.Http;

using Smartsheet.Api.Models;

//and build connection

SmartsheetClient sm = new SmartsheetBuilder().SetAccessToken("myToken").Build();

// after - get all sheets

      ```
PaginatedResult<Sheet> sheets = sm.SheetResources.ListSheets(

       new SheetInclusion[] { SheetInclusion.SOURCE },

       new PaginationParameters(

        true,      // includeAll

        null,      // int pageSize

        null)      // int page

      );

get error - **Smartsheet.Api.Internal.Http.HttpClientException: "There was an issue connecting."**
PS: in project from git i have same error, RetryHttpClient() and ProxyHttpClient("localhost", 8888) do not work :(

image.id versus image.imageId

Image object inside cells doesn't have the same structure as user profile image.

While reading a cell containning an image the object is correctly parsed, yet on the user profile image the id property is empty.

Cell response from reading a sheet ( https://api.smartsheet.com/2.0/sheets/999999999?level=2 ):

{
	"columnId": 761346099832708,
	"value": "Annotation 2020-03-26 082946.png",
	"displayValue": "Annotation 2020-03-26 082946.png",
	"formula": "=SYS_CELLIMAGE(\"Annotation 2020-03-26 082946.png\",\"gEQqGCr7KyzXcVoWi7J-tC\",168,878,\"Annotation 2020-03-26 082946.png\")",
	"image": {
		"id": "gEQqGCr7KyzXcVoWi7J-tC",
		"height": 168,
		"width": 878,
		"altText": "Annotation 2020-03-26 082946.png"
	}
}

User profile reponse (https://api.smartsheet.com/2.0/users/me)

"profileImage": {
	"imageId": "u!1!2v1Yf0456Q!U1PZ3znPe_w!DQqovAB1kle",
	"height": 1050,
	"width": 1050
}

Both objets refers to the same c# class Smartsheet.Api.Models.Image

/// <summary>
/// Get Image Id.
/// </summary>
/// <returns> the Id </returns>
public string ImageId
{
    get { return imageId; }
    set { imageId = value; }
}

I can imagine 2 solutions: introduce a new class for user profile image (and avoid regressions for other languages) or modify the curl response of userprofile.

Can't get columns

var cells = new Cell[] { new Cell.AddCellBuilder(sheet.GetColumnByIndex(0).Id, "test").Build(), };
Can't get columnID; column-objects are null.
All my sheets are in workspaces, but I tried to make a new sheet in the Sheets-folder. Still I can't get columns-objects.

I get sheet-id, name etc.. I can see that columns on the webapp.

Json deserialization error

An invalid date was set to a date cell : "2020-02-19T13:57:42Z" using zapier.

Trying to read the sheet using curl call is working and returning information, yet the c# wrapper is crashing while deserializing the date.

Stack trace:

Unable to cast object of type 'System.DateTime' to type 'System.String'. ex.Errror:   at Smartsheet.Api.Internal.Json.ObjectValueTypeConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Populate(JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerProxy.PopulateInternal(JsonReader reader, Object target)
   at Smartsheet.Api.Internal.Json.CellTypeConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize[T](JsonReader reader)

AttachmentSubType is always null, even for Google Drive attachments

Hi,

The property AttachmentSubType is always null, even for Google Drive attachments. Theh REST API documentation states that this property is only populated for Google Drive attachments, but our testing with the C# SDK indicates it is always null. Is this consistent with the values returned from the REST API or is it a bug?

REST API documentation for the AttachmentSubType property: http://www.smartsheet.com/developers/api-documentation#h.cfv5wpkrtmkr

Best,
Stein J. Gran

widget positions

The widget positions that I received from SmartSheet API do not match the positions on sight. How can I get right widget positions?

RestSharp dependency error if updated

If you updated RestSharp to the latest version (v106.2.1) it causes a null reference exception when initializing the SmartsheetClient with new SmartsheetBuilder().SetAccessToken(accessToken).Build().

Save Attachment from System.IO.Stream

Please add a new AttachFile method for streams to SheetAttachmentResourcesImpl.

Below is the method. I don't have a working build of the source code to implement myself.

`private Attachment AttachFile(string path, string fileName, string contentType, Stream stream)
{
Utility.Utility.ThrowIfNull(fileName);
Utility.Utility.ThrowIfNull(stream);

        if (contentType == null)
        {
            contentType = "application/octet-stream";
        }

        HttpRequest request = CreateHttpRequest(new Uri(this.Smartsheet.BaseURI, path), HttpMethod.POST);

        request.Headers["Content-Disposition"] = "attachment; filename=\"" + fileName + "\"";

        HttpEntity entity = new HttpEntity();
        entity.ContentType = contentType;

        MemoryStream ms = new MemoryStream();
        stream.CopyTo(ms);

        entity.Content = ms.ToArray();
        entity.ContentLength = fi.Length;
        request.Entity = entity;

        HttpResponse response = this.Smartsheet.HttpClient.Request(request);

        Attachment attachment = null;
        switch (response.StatusCode)
        {
            case HttpStatusCode.OK:
                attachment = this.Smartsheet.JsonSerializer.deserializeResult<Attachment>(
                    response.Entity.GetContent()).Result;
                break;
            default:
                HandleError(response);
                break;
        }

        this.Smartsheet.HttpClient.ReleaseConnection();

        return attachment;
    }`

Thanks,

Dan

Async Task Based HTTP Operations

Right now all the HTTP operations in the smartsheet SDK are synchronous. In high-traffic systems that are doing a lot of network I/O this can cause thread starvation and issues around scalability.

This is related to #69 in that a .NET Core SDK ought to support async operations as a standard - so perhaps this should be part of that issue?

Thanks guys!

Error while getting a Report

I'm getting the following error while accessing a report

Error:

The value 'Smartsheet.Api.Models.Cell' is not of type 'Smartsheet.Api.Models.ReportCell' and cannot be used in this generic collection.\r\nParameter name: value

Code:

            var ss = new SmartsheetBuilder()
                .SetAccessToken("XXXXXXXXXXXXXXXXXXXXXXXX")
                .Build();

            Report report = null;

            try
            {
                report = ss.ReportResources.GetReport(XXXXXXXXXXXXXXXXX,
                              new ReportInclusion[] { ReportInclusion.SOURCE_SHEETS }, 500, 1);
            }
            catch (System.Exception ex)
            {
                throw;
            }

Getting API failure while using Smartsheet-csharp-sdk- 2.2.1 version

Hi!
I am using .NetFramework 4.7 and have installed packages as given below:

Newtonsoft.Json.dll - 11.0.1
RestSharp.dll - 106.11.4
Smartsheet-csharp-sdk.dll - 2.2.1

While installing Smartsheet-csharp-sdk.dll - 2.2.1, dependencies required, any version >105.2.3 AND >10.0.2 for RestSharp and Newtonsoft.Json respectively.
image

When I try to give SmartsheetBuilder API call I am getting below exception.
"System.IO.FileLoadException
HResult=0x80131040
Message=Could not load file or assembly 'RestSharp, Version=105.2.3.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source=smartsheet-csharp-sdk
StackTrace:
at Smartsheet.Api.Internal.SmartsheetImpl..ctor(String baseURI, String accessToken, HttpClient httpClient, JsonSerializer jsonSerializer)
at Smartsheet.Api.SmartsheetBuilder.Build()
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)"

Does anyone have any idea how to resolve this issue?

I can't upgrade Newtonsoft.Json and RestSharp packages due to it's dependency.

SmartsheetBuilder.Build() fails - "Invalid Class"

SmartsheetBuilder.Build() throws a System.Management.Management.ManagementException "Invalid Class" at runtime.

Steps:

  • Fire up a new project (console, etc)
  • Add NuGet package for smartsheet-csharp-sdk (2.93.1)
  • Run the following:
         var accessToken = "YOUR_TOKEN";
            var foo = new SmartsheetBuilder()
                .SetAccessToken(accessToken)
                .Build(); 

The error is thrown in Utils.cs GetOSFriendlyName() line 55. I have no idea why it is doing this. It was working fine, and then suddenly no longer. I wonder if a Windows 10 update changed some system thing this is trying to call? That is the only thing that happened on my system between the time my project was working, and not.

OS: Windows 10 x64, v1903 (Build 18362,836)
VS: v16.5.0 Preview 1.0
Project Target Type: .Net Framework 4.7.2

Dropbox and Evernote are missing in the AttachmentType enum

Hi,

Whhen getting attachments, the AttachmentType value specifies where the attachment is from, like Google Drive and Box.com. However, for attachments from Dropbox and Evernote the AttachmentType value is empty when using the C# SDK. But the REST API documentation says at least Dropbox is returned from the API: http://www.smartsheet.com/developers/api-documentation#h.cfv5wpkrtmkr

When digging in the source code, the /Api/Models/AtatchmentType.cs enum is missing both the DROPBOX and EVERNOTE values in the enum. I added these to a local copy of the source code, and these values were then returned from the C# SDK when getting attachments.

You may want to add these two values to the AttachmentType enum, and also update the REST API documentation so that it mentions that EVERNOTE can also be returned.

reference error

While compiling master branch, I got an error from 'ShareResourcesImpl.cs', and it's because VS couldn't locate the ShareScope class. Then I've found out the class is excluded from the project.

After including it, I could compile the project.
I am wondering if you are replacing the ShareScope with some new type or somthing?

Also I've found the NUnit package is missing from the packages.config of IntegrationTestSDK project.

Cheers,
Daniel

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.