1

core/batch - Invaid input

(04/11/2017 01:07:19 отредактировано prabhu.janakiraman)

Тема: core/batch - Invaid input

I'm using core/batch with .Net Framework, getting error "Invaid input" if I use special character "&" in any batch input.
Currently using StringContent Method, Encoding type as " Encoding.UTF8", Mediatype as "application/x-www-form-urlencoded"

Kindly give any suggestion. Thanks in advance.

Code :
var mainParam = new StringBuilder();
mainParam.Append("svc=").Append("core/batch");
mainParam.Append("&params=").Append(mainParamsString);
mainParam.Append("&sid=").Append(sessionID);
var content = new StringContent(Uri.EscapeUriString(mainParam.ToString()), Encoding.UTF8, "application/x-www-form-urlencoded");
var response = client.PostAsync(Constants.RequestUri, content).Result;

Thanks
J Prabhu
2

core/batch - Invaid input

Re: core/batch - Invaid input

Please send me API string

3

core/batch - Invaid input

(04/11/2017 01:00:04 отредактировано prabhu.janakiraman)

Re: core/batch - Invaid input

svc : core/batch

params : {"params":[{"svc":"resource/update_zone","params":{"n":"Test 1","d":"test desc ","id":0,"rid":15067605,"t":3,"w":200,"f":48,"c":2568583984,"tc":16733440,"ts":12,"min":0,"max":18,"i":4294967295,"libId":0,"path":"","b":{"min_x":-83.7355982459,"min_y":42.2118872472,"max_x":-83.7341217541,"max_y":42.2129847528,"cen_x":-83.73486,"cen_y":42.212436},"p":[{"x":-83.73486,"y":42.212436,"r":196}],"ct":1487785548,"mt":1487785548,"itemId":*******,"callMode":"create"}}],"flags":"0"}

Thanks
J Prabhu
4

core/batch - Invaid input

Re: core/batch - Invaid input

you can replace & with %26 or using UrlEncode method please find the simple vb .net code below to add geofence

Imports System.Net
Imports System.Data
Imports System.IO




Partial Class _Default
    Inherits System.Web.UI.Page
    Public wialonurl As String = "http://url/wialon/ajax.html?svc="
    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load

        Dim s As String = Test("ac7455d3b5ae0bcdc5d988e92f9d816a")
    End Sub
    
    Public Function Test(sid As String) As String
        Dim st As String = ""
        Dim objText As String
        Dim a As String = "{%22svc%22:%22resource/update_zone%22,%22params%22:{%22itemId%22:%222378%22,%22id%22:%220%22,%22callMode%22:%22create%22,%22n%22:%22" & WebUtility.UrlEncode("MohammadTest & & & 1") & "%22,%22t%22:%223%22,%22w%22:%22100%22,%22f%22:%2248%22,%22c%22:%222583625728%22,%22tc%22:%2216733440%22,%22p%22:[{%22x%22:%2235.22222%22,%22y%22:%2230.2222222%22,%22r%22:%2250%22}]}}"
        Dim b As String = "{%22svc%22:%22resource/update_zone%22,%22params%22:{%22itemId%22:%222378%22,%22id%22:%220%22,%22callMode%22:%22create%22,%22n%22:%22MohammaTest %26 %26 % 26 %22,%22t%22:%223%22,%22w%22:%22100%22,%22f%22:%2248%22,%22c%22:%222583625728%22,%22tc%22:%2216733440%22,%22p%22:[{%22x%22:%2235.22222%22,%22y%22:%2230.2222222%22,%22r%22:%2250%22}]}}"

        Dim URL = wialonurl & "core/batch&params=[" & a & "," & b & "]&sid=" & sid
        Try
            Dim req = DirectCast(HttpWebRequest.Create(URL), HttpWebRequest)
            Using reader = New StreamReader(req.GetResponse().GetResponseStream())
                objText = reader.ReadToEnd()
            End Using
            If objText.Contains("error") Then
                st = "0"
            Else
                st = "1"
            End If
        Catch ex As Exception
            st = "0"
        End Try
        Return st
    End Function


    
End Class