Hello,

If I write this in Google Chrome it works:

http://dbserv3:8086/query?q=SHOW+DATABASES

But, if I write this, it does not work:

http://dbserv3:8086/write?db=PRUEBA&pm_ccc&pm=0043P&env_cecre=1+valor=127.3&calidad=0&origen=auto

Which it is the way to pass parameters when I want to write in Influxdb?

Thanks and regards

2016-07-19 9:24 GMT+02:00 tresComunes tresEnergia <[email protected]>:

> Hello,
>
> This is the body of the POST:
>
> *URL:* http://dbserv3:8086/write?db=PRUEBA
> *Parameters:*
> pm_ccc&pm=0043P&env_cecre=1&valor=127.3&calidad=0&origen=auto
>
>
> enviarInflush("http://dbserv3:8086/write?db=PRUEBA";, parameters);
>
>
>
> public static String enviarInflush(String url, String param)
>         {
>             try
>             {
>                 // create a request
>                HttpWebRequest request =
> (HttpWebRequest)WebRequest.Create(new Uri(url));
>                request.Accept = "*/*";
>                request.ContentType = "*/*";
>                request.Method = "POST";
>
>                 UTF8Encoding encoding = new UTF8Encoding();
>                 Byte[] bytes = encoding.GetBytes(param);
>
>                 Stream str = request.GetRequestStream();
>                 str.Write(bytes, 0, bytes.Length);
>                 str.Close();
>
>                 HttpWebResponse response =
> (HttpWebResponse)request.GetResponse();
>                 StreamReader strRd = new
> StreamReader(response.GetResponseStream());
>                 string result = strRd.ReadToEnd();
>
>                 return result;
>             }
>             catch (Exception e)
>             {
>                 return e.StackTrace;
>             }
>         }
>
> Thank you for your answer,
>
> Regards
>
> 2016-07-19 7:30 GMT+02:00 Sean Beckett <[email protected]>:
>
>> It seems likely there is a syntax error somewhere in the code. I don't
>> read C# well enough to recreate the output. Can you include an example of
>> the actual body of the POST?
>>
>> On Mon, Jul 18, 2016 at 9:06 AM, Brannon King <[email protected]>
>> wrote:
>>
>>> Here's a bit of working sample code. I'm using HttpClient.PostAsync
>>> called periodically. I'm not setting any headers. I'm using
>>> the PushStreamContent class for my content. I loop through the items in the
>>> queue and write them to the stream after converting them to UTF8.
>>>
>>> private async Task SendQueue(ConcurrentQueue<char[]> queue, string
>>> retentionPolicyName)
>>> {
>>> var content = CreateContent(queue);
>>> var uri = new Uri(_influxHttpdAddress).SetPath(_port, "write");
>>> if (!_influxHttpdAddress.Contains("db="))
>>> uri = uri.AddQuery("db", _databaseName);
>>> if (!_influxHttpdAddress.Contains("rp="))
>>> uri = uri.AddQuery("rp", retentionPolicyName);
>>> try
>>> {
>>> var response = await _client.PostAsync(uri,
>>> content).ConfigureAwait(false);
>>> if (response.StatusCode == HttpStatusCode.BadRequest)
>>> throw new Exception("Write failure: " + await
>>> response.Content.ReadAsStringAsync().ConfigureAwait(false));
>>> // for debugging:
>>> //if (response.StatusCode == HttpStatusCode.InternalServerError)
>>> // throw new Exception("Server error: " + await
>>> response.Content.ReadAsStringAsync().ConfigureAwait(false));
>>> //if (response.StatusCode != HttpStatusCode.NoContent)
>>> // throw new Exception("Write failure: " + await
>>> response.Content.ReadAsStringAsync().ConfigureAwait(false));
>>> }
>>> catch (Exception ex)
>>> {
>>> logger.Error(ex);
>>> // may fail during shutdown
>>> }
>>> }
>>>
>>> --
>>> Remember to include the InfluxDB version number with all issue reports
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "InfluxDB" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at https://groups.google.com/group/influxdb.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/influxdb/c9acc658-018d-4a77-a5ba-000a9119f991%40googlegroups.com
>>> <https://groups.google.com/d/msgid/influxdb/c9acc658-018d-4a77-a5ba-000a9119f991%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Sean Beckett
>> Director of Support and Professional Services
>> InfluxDB
>>
>
>

-- 
Remember to include the InfluxDB version number with all issue reports
--- 
You received this message because you are subscribed to the Google Groups 
"InfluxDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/influxdb.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/influxdb/CANRwFL9Bzm2wbAWnY4VjLJj_iZ2DM7yKQ4MdUDuwuy3vZDx03A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to