.Net Framework e CURL

martedì 09 ottobre 2012 - 16.26
Tag Elenco Tags  C#  |  .NET 4.0  |  Windows Server 2008  |  Visual Studio 2010  |  SQL Server 2008

TomClancy Profilo | Junior Member

sto cercando un sistema per gestire un post request utilizzando c#
curl -X POST \ -H "X-Parse-Application-Id: xxxxx" \ -H "X-Parse-REST-API-Key: yyyyy" \ -H "Content-Type: application/json" \ -d '{ "channels": [ "" ], "data": { "alert": "Message alert" } }' \ https://website.com/

da vero niubbo , googlando un po' in giro ho provato una cosa del tipo...

WebRequest request = WebRequest.Create("https://website.com/"); request.ContentType = "application/json"; request.Method = "POST"; request.Headers["X-Parse-Application-Id"] = "xxxxx"; request.Headers["X-Parse-REST-API-Key"] = "yyyyy"; byte[] buffer = Encoding.GetEncoding("UTF-8").GetBytes("channels=''&data=Message alert"); string result = System.Convert.ToBase64String(buffer); Stream reqstr = request.GetRequestStream(); reqstr.Write(buffer, 0, buffer.Length); reqstr.Close(); WebResponse response = request.GetResponse();

... ammetto di navigare nel buio ... qualcuno ha qualche suggerimento o consiglio?
Grazie


Michele Levada

AGGIORNAMENTO DEL 2012.10.10
Ho risolto... era praticamente quasi tutto giusto.
Essendo difficile in questi casi capire cosa non va per il verso giusto consiglio di utilizzare un software come FIDDLER che permette di capire come viene datta la chiamata POST.

Ciao
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2025
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5