Example JSON service request

You need a valid Access Token before accessing the 2BA web services.

  1. one time: Acquire the Refresh- and Access Token using OAuth2 Flow1 (Resource Owner Password Credentials Grant) or OAuth2 Flow2 (Authorization Code). Store the Tokens.
  2. continuously: Only(!) retrieve the access token if expired using the Refresh Token service (Refresh Access Token Service). Store the Access Token.
  3. Invoke the desired service, supplying the Access Token in the request header:

C# code example

<br>private void GetProductJson()
	var request = (HttpWebRequest)WebRequest.Create(GlobalVariables.ResourceServer + "/json/product/details/" + this.txtGTIN.Text);
	request.Method = "GET";
	request.Headers.Add("Authorization", "Bearer " + _accessToken);
	var response = (HttpWebResponse)request.GetResponse();
	// Use your own preferred JSON parser here.
	XmlReader reader = JsonReaderWriterFactory.CreateJsonReader(response.GetResponseStream(), new XmlDictionaryReaderQuotas());
	var root = XElement.Load(reader);
	// The fields we'd like to extract
	var id = root.XPathSelectElement("//ID");
	var manufacturerGLN = root.XPathSelectElement("//ManufacturerGLN");
	var manufacturerName = root.XPathSelectElement("//ManufacturerName");
	txtId.Text = (id == null) ? null : id.Value;
	txtManufacturerGLN.Text = (manufacturerGLN == null) ? null : manufacturerGLN.Value;
	txtManufacturerName.Text = (manufacturerName == null) ? null : manufacturerName.Value;
Wat biedt 2BA voor u als Installateur Wat biedt 2BA voor u als Groothandel Wat biedt 2BA voor u als Fabrikant Wat biedt 2BA voor u als Software Partner
This site is registered on wpml.org as a development site.