2016-11-05 40 views
0

在Chrome開發者工具,XHR選項,我有這樣的信息:Array參數不工作

請求URL:https://pmv.geocontrol.com.br/pontovitoria/svc/json/db/listarPontosDeParada

請求負載: {listaIds:[216,147, 607,601,79]}

我試圖改變它在一個獨特的HTML,像

https://pmv.geocontrol.com.br/pontovitoria/svc/json/db/listarPontosDeParada?listaIds[0]=216&listaIds[1]=147&listaIds[2]=607&listaIds[3]=601&listaIds[4]=79

但我收到此錯誤

errorClass: 「javax.servlet.ServletException」, 消息: 「org.postgresql.util.PSQLException:錯誤:語法錯誤處或附近 」)「 的位置:273」

我正在開發一個應用程序在C#中,我嘗試這個帖子請求:

public async void GetList() 
{ 
     int[] list = new int[] { 216, 147, 607, 601, 79 }; 

     var client = new HttpClient(); 
     client.DefaultRequestHeaders.Add("User-Agent", "Other"); 
     client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); 
     client.DefaultRequestHeaders.IfModifiedSince = DateTime.Now; 

     Dictionary<string, string> bodyProperties = new Dictionary<string, string>(); 

     int i = 0; 
     foreach (var pto in list) 
     { 
      bodyProperties.Add("listaIds[" + i.ToString() + "]", pto.ToString()); 
      i++; 
     } 

     var content = new FormUrlEncodedContent(bodyProperties); 
     var response = await client.PostAsync("https://pmv.geocontrol.com.br/pontovitoria/svc/json/db/listarPontosDeParada", content); 
     var responseString = await response.Content.ReadAsStringAsync(); 
} 

這是行不通的。我該如何解決它?

+0

獨特的URL例子也不管用? –

+0

看起來像格式錯誤的JSON給我。您在數組名稱和數組之間缺少冒號。 – Lathejockey81

回答