x
Developer

Diagnosing INVALID_REQUEST_ERROR

Submitting a V2 API request to:
url = https://connect.squareup.com/v2/CBASEMVn_aQuXyMe93tfKwApGPM/transactions
with POSTed data of:
{
"idempotency_key": "91750",
"billing_address": {
"address_line_1": "4433 SW 48th AV",
"address_line_2": "",
"locality": "Portland",
"administrative_district_level_1": "OR",
"postal_code": "97221",
"country": "US"
},
"amount_money": {
"amount": 10,
"currency": "USD"
},
"card_nonce": "CBASEJuQWW4DsEFg1N2io4fYB1Q",
"delay_capture": false,
"buyer_email_address": "support@example.com"
}

Generates an INVALID_REQUEST_ERROR.

How do I find details about specifically what it is seeing wrong with this request? According to the documentation this should be a valid request.

Tags (1)
6,268 Views
Message 1 of 6
Report
5 REPLIES 5
Developer

Seems I was missing the '/locations' path element in the URL

6,265 Views
Message 2 of 6
Report
Square

Sorry I didn't catch your post yesterday, glad you found it! 

 

Let us know if anything else comes up, I can pass it to our developers if need be. 

6,263 Views
Message 3 of 6
Report

Hi, Having a real problem getting the api v2 working. How do I turn on debugging to see what is or is not being posted correctly within the sandbox? I am using php (process-card.php)? I was able to turn on debug within connect: [DEBUG] HTTP Request body  ~BEGIN~ {"card_nonce":"CBASEGre99XsFfF8K81884vyzT0","amount_money":{"amount":100,"currency":"USD"},"idempotency_key":"581c1b872605a"} ~END~ * About to connect() to connect.squareup.com port 443 (#0) *   Trying 74.122.189.136... * connected * Connected to connect.squareup.com (74.122.189.136) port 443 (#0) * Initializing NSS with certpath: sql:/etc/pki/nssdb *   CAfile: /etc/pki/tls/certs/ca-bundle.crt   CApath: none * SSL connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 * Server certificate: * subject: CN=*.squareup.com,O="Square, Inc.",L=San Francisco,ST=California,C=US * start date: Dec 02 17:16:03 2015 GMT * expire date: Dec 16 17:46:01 2016 GMT * common name: *.squareup.com * issuer: CN=Entrust Certification Authority - L1K,OU="(c) 2012 Entrust, Inc. - for authorized use only",OU=See www.entrust.net/legal-terms,O="Entrust, Inc.",C=US > POST /v2/locations/%7B%0A%20%20%22locations%22%3A%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22id%22%3A%20%2218YC4JDH91E1H%22%2C%0A%20%20%20%20%20%20%22name%22%3A%20%22your%20location%20name%22%2C%0A%20%20%20%20%20%20%22address%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22address_line_1%22%3A%20%22123%20Main%20St%22%2C%0A%20%20%20%20%20%20%20%20%22locality%22%3A%20%22San%20Francisco%22%2C%0A%20%20%20%20%20%20%20%20%22administrative_district_level_1%22%3A%20%22CA%22%2C%0A%20%20%20%20%20%20%20%20%22postal_code%22%3A%20%2294114%22%2C%0A%20%20%20%20%20%20%20%20%22country%22%3A%20%22US%22%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%22timezone%22%3A%20%22America%2FLos_Angeles%22%2C%0A%20%20%20%20%20%20%22capabilities%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%22CREDIT_CARD_PROCESSING%22%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%0A%20%20%5D%0A%7D/transactions HTTP/1.1 User-Agent: Square-Connect-PHP/2.0.0.1 Host: connect.squareup.com Accept: application/json Content-Type: application/json Authorization: Bearer sandbox-xxxxxxxxxxxxxxxxx Content-Length: 125 < HTTP/1.1 404 Not Found < Content-Type: application/json < Vary: Origin, Accept-Encoding < X-Content-Type-Options: nosniff < X-Download-Options: noopen < X-Frame-Options: SAMEORIGIN < X-Permitted-Cross-Domain-Policies: none < X-Xss-Protection: 1; mode=block < Date: Fri, 04 Nov 2016 05:24:23 GMT < Keep-Alive: timeout=60 < Strict-Transport-Security: max-age=631152000 < content-length: 648 <  * Connection #0 to host connect.squareup.com left intact [DEBUG] HTTP Response body ~BEGIN~ {"errors":[{"category":"INVALID_REQUEST_ERROR","code":"NOT_FOUND","detail":"API endpoint for URL path `/v2/locations/{\n  \"locations\": [\n    {\n      \"id\": \"18YC4JDH91E1H\",\n      \"name\": \"your location name\",\n      \"address\": {\n        \"address_line_1\": \"123 Main St\",\n        \"locality\": \"San Francisco\",\n        \"administrative_district_level_1\": \"CA\",\n        \"postal_code\": \"94114\",\n        \"country\": \"US\"\n      },\n      \"timezone\": \"America/Los_Angeles\",\n      \"capabilities\": [\n        \"CREDIT_CARD_PROCESSING\"\n      ]\n    }\n  ]\n}/transactions` and HTTP method `POST` is not found."}]} ~END~ * Closing connection #0 Of course I am using a bogus Location as well Thanks, Larry
6,171 Views
Message 4 of 6
Report
Alumni

What kind of debugging are you interested in? It seems like your error is that you are adding things as url parameters instead of a POST body. Doest that help? 

6,164 Views
Message 5 of 6
Report

Hi,   I am using php and followed all the instructions here at: https://github.com/square/connect-api-examples/tree/master/connect-examples/v2/php_payment   And it does not work as stated. So I turned on debug in /vendor/square/connect/lib/Configuration.php to see if i could find out why this doesn't work and all I get INVALID_REQUEST_ERROR.   Any help would be great.   Thanks, Larry
6,163 Views
Message 6 of 6
Report