Error signing in with the error INPUT_VALIDATION_ERROR

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Luca Daniel
    Junior Member
    • Aug 2016
    • 14

    #1

    Error signing in with the error INPUT_VALIDATION_ERROR

    Hi,

    I am getting INPUT_VALIDATION_ERROR while logging into betfair api. I am following the docs, but it was of no use with this particular error code.

    I'd appreciate if anyone could guide me in the right direction.

    Here is my swift code

    Code:
    let request = NSMutableURLRequest(URL: NSURL(string: "https://identitysso.betfair.com/api/login")!)
            request.HTTPMethod = "POST"
    
    
                    request.setValue("application/json", forHTTPHeaderField: "Accept")
            request.setValue("MY_APP_KEY", forHTTPHeaderField: "X-Application")
    
    
            let postString = "username=MY_USER_NAME&password=MY_PASSWORD"
            request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding)
    
            let task = NSURLSession.sharedSession().dataTaskWithRequest(request) { data, response, error in
                guard error == nil && data != nil else {                                                          // check for fundamental networking error
                    print("error=\(error)")
                    return
                }
    
                if let httpStatus = response as? NSHTTPURLResponse where httpStatus.statusCode != 200 {           // check for http errors
                    print("statusCode should be 200, but is \(httpStatus.statusCode)")
                    print("response = \(response)")
                }
    
                let responseString = NSString(data: data!, encoding: NSUTF8StringEncoding)
                print("responseString = \(responseString)")
            }
            task.resume()
    Please Help
  • jabe
    Senior Member
    • Dec 2014
    • 705

    #2
    I'm not starting from the best place to help you, as I don't know what language you're using and my current program uses the Desktop Application login method.

    Is this the third of the login options ("Interactive Login - API Endpoint")?

    I'll assume you replaced key, username, and password with strings for the usual reason.

    Comment

    • betdynamics
      Junior Member
      • Sep 2010
      • 534

      #3
      Make sure that your password doesn't contain any "invalid" characters.

      From memory, I think that some of the punctuation characters are treated as invalid.

      Comment

      • Luca Daniel
        Junior Member
        • Aug 2016
        • 14

        #4
        Originally posted by betdynamics View Post
        Make sure that your password doesn't contain any "invalid" characters.

        From memory, I think that some of the punctuation characters are treated as invalid.
        My password just has letters and numbers. I even changed the password once and tried it.

        If I curl the API with the same parameters, it works smoothly. The headers I am using in both places are same too.

        Comment

        • Luca Daniel
          Junior Member
          • Aug 2016
          • 14

          #5
          Yes Sir. I have done all that.

          Comment

          • betdynamics
            Junior Member
            • Sep 2010
            • 534

            #6
            I would double-check your encoding.

            If you can compare the output of the encoding from the curl and compare it what you are producing from swift, then that may point you in the right direction.

            Comment

            • Luca Daniel
              Junior Member
              • Aug 2016
              • 14

              #7
              Originally posted by betdynamics View Post
              I would double-check your encoding.

              If you can compare the output of the encoding from the curl and compare it what you are producing from swift, then that may point you in the right direction.
              That did it. I somehow managed to get the login working. But the iOS sdk has many issues. I am gonna write my own wrapper around the API.

              Thanks a lot for the help. Much appreciate it.

              Comment

              • talharizwaan
                Junior Member
                • Nov 2024
                • 1

                #8
                Originally posted by Luca Daniel View Post
                Hi,

                I am getting INPUT_VALIDATION_ERROR while logging into betfair api. I am following the docs, but it was of no use with this particular error code.

                I'd appreciate if anyone could guide me in the right direction.

                Here is my swift code

                Code:
                let request = NSMutableURLRequest(URL: NSURL(string: "https://identitysso.betfair.com/api/login")!)
                request.HTTPMethod = "POST"
                
                
                request.setValue("application/json", forHTTPHeaderField: "Accept")
                request.setValue("MY_APP_KEY", forHTTPHeaderField: "X-Application")
                
                
                let postString = "username=MY_USER_NAME&password=MY_PASSWORD"
                request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding)
                
                let task = NSURLSession.sharedSession().dataTaskWithRequest(request) { data, response, error in
                guard error == nil && data != nil else { // check for fundamental networking error
                print("error=\(error)")
                return
                }
                
                if let httpStatus = response as? NSHTTPURLResponse where httpStatus.statusCode != 200 { // check for http errors
                print("statusCode should be 200, but is \(httpStatus.statusCode)")
                print("response = \(response)")
                }
                
                let responseString = NSString(data: data!, encoding: NSUTF8StringEncoding)
                print("responseString = \(responseString)")
                }
                task.resume()
                Please Help
                globe sim registration



                It looks like you're encountering the INPUT_VALIDATION_ERROR because the Betfair API expects the data to be sent in a specific format and with the correct headers zz0.rfl9lqqu5vzz

                Comment

                • rye
                  Junior Member
                  • Sep 2019
                  • 4

                  #9
                  Originally posted by Luca Daniel View Post
                  Hi,

                  I am getting INPUT_VALIDATION_ERROR while logging into betfair api. I am following the docs, but it was of no use with this particular error code.

                  I'd appreciate if anyone could guide me in the right direction.

                  Here is my swift code

                  Code:
                  let request = NSMutableURLRequest(URL: NSURL(string: "https://identitysso.betfair.com/api/login")!)
                  request.HTTPMethod = "POST"
                  
                  
                  request.setValue("application/json", forHTTPHeaderField: "Accept")
                  request.setValue("MY_APP_KEY", forHTTPHeaderField: "X-Application")
                  
                  
                  let postString = "username=MY_USER_NAME&password=MY_PASSWORD"
                  request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding)
                  
                  let task = NSURLSession.sharedSession().dataTaskWithRequest(request) { data, response, error in
                  guard error == nil && data != nil else { // check for fundamental networking error
                  print("error=\(error)")
                  return
                  }
                  
                  if let httpStatus = response as? NSHTTPURLResponse where httpStatus.statusCode != 200 { // check for http errors
                  print("statusCode should be 200, but is \(httpStatus.statusCode)")
                  print("response = \(response)")
                  }
                  
                  let responseString = NSString(data: data!, encoding: NSUTF8StringEncoding)
                  print("responseString = \(responseString)")
                  }
                  task.resume()
                  Please Help
                  Because the password contains special symbols, PHP uses the rawurlencode() function to escape the password and then sends it, so you can log in normally.

                  Comment

                  Working...
                  X