Bilal bouker
New member
- Joined
- Sep 13, 2020
- Messages
- 1
- Programming Experience
- 1-3
Hi everyone
I have a program desktop called API used httpclient
this API => jomla_sandbox
all URL it's working (post ,get ) but this
POST
Sandbox-Secure Voucher
==> jomla_sandbox
I have problem because is accepts param in the header I try all code when I know or find after serach but it's not working.
this some code when I'm trying:
======CODE 1=========
client.BaseAddress = new Uri(uri);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Properties.Settings.Default.TOKEN);
client.DefaultRequestHeaders.Accept.Add( Add("product_id", "6");
HttpResponseMessage response = await client.PostAsJsonAsync("api/voucher");
return reports = await response.Content.ReadAsAsync<Voucher>();
======CODE 2=========
var clientr = new RestClient("https://jomla-api-sandbox.kushok.com:8802/index.php/api/vouche/secure?product_id=6");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/x-www-form-urlencoded");
request.AddParameter(("product_id", 6);
IRestResponse response = clientr.Execute(request);
var result = response.Content;
=====================
please any one can help me
I have a program desktop called API used httpclient
this API => jomla_sandbox
all URL it's working (post ,get ) but this
POST
Sandbox-Secure Voucher
==> jomla_sandbox
I have problem because is accepts param in the header I try all code when I know or find after serach but it's not working.
this some code when I'm trying:
======CODE 1=========
client.BaseAddress = new Uri(uri);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Properties.Settings.Default.TOKEN);
client.DefaultRequestHeaders.Accept.Add( Add("product_id", "6");
HttpResponseMessage response = await client.PostAsJsonAsync("api/voucher");
return reports = await response.Content.ReadAsAsync<Voucher>();
======CODE 2=========
var clientr = new RestClient("https://jomla-api-sandbox.kushok.com:8802/index.php/api/vouche/secure?product_id=6");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/x-www-form-urlencoded");
request.AddParameter(("product_id", 6);
IRestResponse response = clientr.Execute(request);
var result = response.Content;
=====================
please any one can help me