I am coding in C# .Net core 6. I have installed the SDK (ZOHOCRMSDK-2.1). I have this code in program.cs:
- var logger = new Logger.Builder().Build();
- UserSignature user = new UserSignature("user@email.xxx");
- Com.Zoho.Crm.API.Dc.DataCenter.Environment environment = USDataCenter.SANDBOX;
- Token token = new OAuthToken.Builder()
- .ClientId("1234567890")
- .ClientSecret("2345678901")
- .RefreshToken("3456789012")
- .Build();
- TokenStore tokenStore = new FileStore("C:\\TokenStore\\sdktoken.txt");
- tokenStore.SaveToken(user, token);
- SDKConfig config = new SDKConfig.Builder().AutoRefreshFields(false).PickListValidation(false).Build();
- new SDKInitializer.Builder()
- .User(user)
- .Environment(environment)
- .Token(token)
- .Store(tokenStore)
- .SDKConfig(config)
- //.ResourcePath(resourcePath)
- .Logger(logger)
- .Initialize();
I added a controller / call to retrieve all Modules (as a test)
- [ApiController]
- [Route("[controller]")]
- public class ModulesController : ZohoBaseController
- {
- private HttpResponseMessage _response;
- private string _rtnData = string.Empty;
- private readonly JsonSerializerSettings _jsonSettings = new JsonSerializerSettings {
- ContractResolver = new CamelCasePropertyNamesContractResolver(),
- Formatting = Formatting.Indented
- };
- [HttpGet(Name = "ModuleList")]
- public HttpResponseMessage List()
- {
- //Get instance of ModulesOperations Class
- ModulesOperations moduleOperations = new ModulesOperations();
- HeaderMap headerInstance = new HeaderMap();
- DateTimeOffset ifModifiedSince = new DateTimeOffset(new DateTime(2020, 05, 15, 12, 0, 0, DateTimeKind.Local));
- headerInstance.Add(ModulesOperations.GetModulesHeader.IF_MODIFIED_SINCE, ifModifiedSince);
- //Call GetModules method that takes headerInstance as parameters
- APIResponse<ResponseHandler> response = moduleOperations.GetModules(headerInstance);
- // Serialise the return data
- _rtnData = JsonConvert.SerializeObject(response, _jsonSettings);
- //_response = Request.CreateResponse(HttpStatusCode.OK);
- _response = new HttpResponseMessage(HttpStatusCode.OK);
- _response.Content = new StringContent(_rtnData, Encoding.UTF8, "application/json");
- return _response;
- }
- }
But this fails with this at "moduleOperations.GetModules(headerInstance)":
- Com.Zoho.API.Exception.SDKException
- HResult=0x80131500
- Message=Input string was not in a correct format.
- Source=ZOHOCRMSDK-2.1
- StackTrace:
- at Com.Zoho.Crm.API.Util.CommonAPIHandler.APICall[T](Type className, String encodeType)
- at Com.Zoho.Crm.API.Modules.ModulesOperations.GetModules(HeaderMap headerInstance)
- at KervPlatformZoho.Controllers.ModulesController.List() in C:\...\Controllers\ModulesController.cs:line 33
- at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
- at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
- at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
- at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
- This exception was originally thrown at this call stack:
- [External Code]
- Inner Exception 1:
- FormatException: Input string was not in a correct format.
I have a record in the TokenStore (file) but it is missing access_token, grant_token, expiry_time and redirect_url.
I created a "Self Client", generated a code and used Postman to "Generate Access Token and Refresh Token". I entered the Refresh Token in the code above.
So - what am I missing?