0

I have created one web app for that I have generated access token via OAuth2.0 My app have all read write permissions but I am not able get response. Same has been working with Merchant's static access token generated from Merchant settings. So Any extra information need to be add in web app. Because Same I have tested with Android app and it is working fine with same App configuration like I have for Web App.

Hello Team, Below is my code snippet. It is working code for production but when I change it to sandbox by changing end point url got response as No content.

using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.IO; using System.Net; using System.Text; using Newtonsoft.Json; using System.Data; using System.Xml; using System.Xml.Linq;

public partial class Login : System.Web.UI.Page { public string strMerchantID { get { return Convert.ToString(ViewState["MerchantID"]); } set { ViewState["MerchantID"] = value; } } public string strEmployeeID { get { return Convert.ToString(ViewState["EmployeeID"]); } set { ViewState["EmployeeID"] = value; } } public string strClientID { get { return Convert.ToString(ViewState["ClientID"]); } set { ViewState["ClientID"] = value; } } public string strAccessToken { get { return Convert.ToString(ViewState["AccessToken"]); } set { ViewState["AccessToken"] = value; } } public string EndPoint { get; set; } public HttpVerb Method { get; set; } private string ContentType = "application/json"; public string ContentType { get { return _ContentType; } set { _ContentType = value; } } public string PostData { get; set; } protected void PageLoad(object sender, EventArgs e) { if (!Page.IsPostBack) { strMerchantID = Request.QueryString["merchantid"]; strEmployeeID = Request.QueryString["employeeid"]; strClientID = Request.QueryString["clientid"]; //btnFirstLoadClick(btnFirstLoad, null); } else { if (!string.IsNullOrEmpty(hdnAccessToken.Value) && Convert.ToString(hdnAccessToken.Value).Contains("#")) { string CompleteQueryString = hdnAccessToken.Value; strAccessToken = CompleteQueryString.Substring(CompleteQueryString.IndexOf("#"), CompleteQueryString.Length - CompleteQueryString.IndexOf("#")).Replace("#accesstoken=", ""); } } } public DataTable XElementToDataTable(XElement x) { DataTable dtable = new DataTable(); XElement setup = (from p in x.Descendants() select p).First(); // build your DataTable foreach (XElement xe in setup.Descendants()) dtable.Columns.Add(new DataColumn(xe.Name.ToString(), typeof(string))); // add columns to your dt var all = from p in x.Descendants(setup.Name.ToString()) select p; foreach (XElement xe in all) { DataRow dr = dtable.NewRow(); foreach (XElement xe2 in xe.Descendants()) dr[xe2.Name.ToString()] = xe2.Value; //add in the values dtable.Rows.Add(dr); } return dtable; } protected void btnGetItemsClick(object sender, EventArgs e) { try { //Manoj (Production) var client = new RestClient(EndPoint, Method, PostData); client.EndPoint = @"https://api.clover.com/v3/merchants/" + strMerchantID + "/"; //@"http:\myRestService.com\api\"; ; client.Method = HttpVerb.GET; client.ContentType = ContentType; client.PostData = ""; var json = client.MakeRequest("items", strAccessToken); json = "{\"tems\":" + json + "}"; XmlDocument doc = (XmlDocument)JsonConvert.DeserializeXmlNode(json); XElement xRoot ; using (XmlNodeReader nodeReader = new XmlNodeReader(doc)) { nodeReader.MoveToContent(); xRoot = XElement.Load(nodeReader); } DataTable dt = XElementToDataTable(xRoot); grdItems.DataSource = dt; grdItems.DataBind(); } catch (Exception) { throw; } }

protected void btnGetOrders_Click(object sender, EventArgs e)
{
    try
    {
        //Manoj (Production)
        var client = new RestClient(EndPoint, Method, PostData);
        client.EndPoint = @"https://api.clover.com/v3/merchants/" + strMerchantID + "/"; //@"http:\\myRestService.com\api\"; ;
        client.Method = HttpVerb.GET;
        client.ContentType ...
(more)

asked 2017-05-05 12:47:23 -0500

Manoj Raul gravatar image

updated 2017-05-08 11:55:56 -0500

Comments

Could you post your debug logs and some code snippets?

If you need some quick guidance on how to create Oauth token using a webapp, please see this video: https://www.youtube.com/watch?v=6riNP...

Sam gravatar image
Sam 2017-05-05 19:17:55 -0500

1 answer

Sort by  
0

I am having this same issue. I can't get my oauth access token to work, but the generated API test token works all the time... Just can't get all my records.

answered 2017-05-06 16:15:53 -0500

rawrkats gravatar image