04-13-2022 10:30 PM
Query from Alejandro Jose Sanchez in #webex4devs space
Webex still accepts Content-Type: application/x-www-form-urlencoded for request?
04-13-2022 10:34 PM
In case of any HTML Form submission, this 'Content-Type' is used.
If you've the specific requirement, you can use the same.
Otherwise, in case of API URL GET or, POST method Requests, we keep it like 'Content-Type': 'application/json; charset=utf-8'
I personally have not tested for long "Content-Type": "application/x-www-form-urlencoded", please let us know if you're facing any problem in doing it.
11-30-2023 12:25 PM - edited 11-30-2023 12:26 PM
Hello Sandiban,
I use the CMS api v3.7 , so far so good everything works EXCEPT the command related to section :
8.1.2 Creating a New Call and Modifying an Active call
POST method performed on the “/calls” node, so i need to use x-www-form-urlencoded
Using Postman it works fine, i use the same command with WebRequest or RestSharp , and impossible to make it work, the request hang until a timeout. I have no issue with credential or network. other commands work perfectly fine.
Are you aware about this kind of behavior ?
Please let me know.
Best
11-30-2023 12:49 PM
Are you working with Cisco Meeting Server (CMS)...you mentioned Webex in the original post?
Are you copying/pasting sample code copied from the Postman code generation feature? Would be surprised if that didn't work well. Are you doing this from C# or Powershell..?
Unfortunately I don't have a Cisco Meeting Server instance to try with in case it is doing something weird on its end
12-01-2023 03:47 AM
With CMS1000 yes.
I copied exact code, i try with custom code using WebRequest as documented and also several stackoverflow example, none of them works, it hang right after sending the Post request.
Very strange
12-04-2023 01:58 PM
I seem to be able to get a simple request to work, though my environment is different:
* OS: Ubuntu 22.04
* DotNet SDK: 7.0
* CMS: 3.8.1
using RestSharp;
using RestSharp.Authenticators;
var options = new RestClientOptions("https://cms38/api/v1")
{
Authenticator = new HttpBasicAuthenticator("administrator", "ciscopsdt"),
RemoteCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true
};
var client = new RestClient(options);
var request = new RestRequest("coSpaces", Method.Post);
var coSpace = new
{
name = "testCoSpace",
uri = "testUri",
callId = "987654321"
};
request.AddObject(coSpace);
var response = await client.PostAsync(request);
var coSpace_id = response.Headers.ToList().Find(x => x.Name == "Location").Value.ToString().Substring("/api/v1/coSpaces/".Length);
Console.WriteLine($"POST /api/v1/coSpaces: SUCCESS\ncoSpace Id: {coSpace_id}");
request = new RestRequest("calls", Method.Post);
request.AddParameter("coSpace", coSpace_id);
response = await client.PostAsync(request);
var call_id = response.Headers.ToList().Find(x => x.Name == "Location").Value.ToString().Substring("/api/v1/calls/".Length);
Console.WriteLine($"POST calls: SUCCESS\nCall Id: {call_id}");
request = new RestRequest($"calls/{call_id}", Method.Delete);
response = await client.DeleteAsync(request);
Console.WriteLine($"DELETE /api/v1/calls: SUCCESS");
request = new RestRequest($"coSpaces/{coSpace_id}", Method.Delete);
response = await client.DeleteAsync(request);
Console.WriteLine($"DELETE /api/v1/coSpaces: SUCCESS");
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide