com.glide.rest.domain.ServiceException: Exception while reading request
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2018 01:49 PM
While making API call using Dotnet we are getting error: com.glide.rest.domain.ServiceException: Exception while reading request. What does this indicate?
- 4,182 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2018 02:42 PM
Could you provide more information around what exactly your API call is doing and what endpoint you're consuming?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2018 06:39 AM
Our API call has two POST methods. One is for adding the request to the cart and the other is for submitting the request. We are using the following end points:
1.https://companyname/api/sn_sc/servicecatalog/items/19c1337b4f7c97c010d3f6e01310c70d/add_to_cart
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2018 01:43 PM
Please see the code snippet we are using for the API calls below:
public static string CreateServiceNowRequest(string test1, string test2, string test3, string name, string password)
{
try
{
string username = name;
string password = password;
string addToCarturl = "https://companyname/api/sn_sc/servicecatalog/items/19c1337b4f7c97c010d3f6e01310c70d/add_to_cart";
string submiturl = "https://companyname/api/sn_sc/servicecatalog/cart/submit_order";
var auth = "Basic " + Convert.ToBase64String(Encoding.Default.GetBytes(username + ":" + password));
HttpWebRequest request = WebRequest.Create(addToCarturl) as HttpWebRequest;
request.Accept = "application/json";
request.ContentType = "application/json";
request.Headers.Add("Authorization", auth);
request.Method = "POST";
var requeststring = "{\"sysparm_quantity\":\"1\", \"variables\":{\"request_type\":\"test1\",\"string2\":\"test2\",\"string3\":\"test3\"}}";
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
{
string json = JsonConvert.SerializeObject(requeststring);
streamWriter.Write(json);
}
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
var res = new StreamReader(response.GetResponseStream()).ReadToEnd();
JObject joResponse = JObject.Parse(res.ToString());
JObject ojObject = (JObject)joResponse["result"];
string cartnum = ((JValue)ojObject.SelectToken("cart_item_id")).Value.ToString();
}
var auth1 = "Basic " + Convert.ToBase64String(Encoding.Default.GetBytes(username + ":" + password));
HttpWebRequest request1 = WebRequest.Create(submiturl) as HttpWebRequest;
request1.Accept = "application/json";
request1.ContentType = "application/json";
request1.Headers.Add("Authorization", auth1);
request1.Method = "Post";
using (var streamWriter = new StreamWriter(request1.GetRequestStream()))
{
string json = JsonConvert.SerializeObject(new
{
});
streamWriter.Write(json);
}
using (HttpWebResponse response = request1.GetResponse() as HttpWebResponse)
{
var res = new StreamReader(response.GetResponseStream()).ReadToEnd();
JObject joResponse = JObject.Parse(res.ToString());
JObject ojObject = (JObject)joResponse["result"];
string incNumber = ((JValue)ojObject.SelectToken("request_id")).Value.ToString();
return incNumber;
}
}
catch (WebException ex)
{
WebResponse errResp = ex.Response;
using (Stream respStream = errResp.GetResponseStream())
{
StreamReader reader = new StreamReader(respStream);
string text = reader.ReadToEnd();
return text;
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2020 01:52 PM
Did you ever figure out the issue?