Need help regarding rest api

hello everyone I am using REST API of shipping service but i am facing certain errors. here’s the image of my block
image

here is the link of API docs please tell me what I am doing wrong. I think the error is most probably in order detail ( Array containing further fields).

it is the create custom order section.

your help will be appreciated

What error? …

1 Like

image you provide is not clear

Error is : ```
Oops! Invalid Data

but i have checked all the data is correct maybe something is wrong in my blocks.

website requires json formatted data in headers

i know i am using the headers see this
image

in this case the data then obvously as well should be in JSON format…
use Do it to get your post text and check its format for example here


also you are using Post and Get at the same time, which does not make sense…

Taifun

but i am using the same header and post text method for other API calls and they are working. this time it is showing missing data but data is not missing. I think this is happening because I am not able to input data in order details correctly see block image and pls tell is this the correct method to show further field in and array.

In other apis you are sending params via Get request but here you need to to send params via POST request and in json format.
You just created a string with procedure not json

no i am using this method in post request see image i am using this image for getting auth token and it is working.
image

see above image and it is working.

I know that but String you are making from procedure is in the GET Request format

Also i am using this mehtod for almost a year in every webiste like onesignal, firebase ,openload and even this website but only this time in this website i am getting an error on on endpoint only.

So try with postman did you get response from api

actually i dont know how to use postman

and again post and get at the same time… use POST or GET, but not both at the same time…
Unbenannt
what exactly prevents you from using a correct JSON format as data?

Taifun

1 Like
curl --location --request POST 'https://apiv2.shiprocket.in/v1/external/orders/create/adhoc' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}' \
--data-raw '{
  "order_id": "224-447",
  "order_date": "2019-07-24 11:11",
  "pickup_location": "Jammu",
  "channel_id": "",
  "comment": "Reseller: M/s Goku",
  "billing_customer_name": "Naruto",
  "billing_last_name": "Uzumaki",
  "billing_address": "House 221B, Leaf Village",
  "billing_address_2": "Near Hokage House",
  "billing_city": "New Delhi",
  "billing_pincode": "110002",
  "billing_state": "Delhi",
  "billing_country": "India",
  "billing_email": "[email protected]",
  "billing_phone": "9876543210",
  "shipping_is_billing": true,
  "shipping_customer_name": "",
  "shipping_last_name": "",
  "shipping_address": "",
  "shipping_address_2": "",
  "shipping_city": "",
  "shipping_pincode": "",
  "shipping_country": "",
  "shipping_state": "",
  "shipping_email": "",
  "shipping_phone": "",
  "order_items": [
    {
      "name": "Kunai",
      "sku": "chakra123",
      "units": 10,
      "selling_price": "900",
      "discount": "",
      "tax": "",
      "hsn": 441122
    }
  ],
  "payment_method": "Prepaid",
  "shipping_charges": 0,
  "giftwrap_charges": 0,
  "transaction_charges": 0,
  "total_discount": 0,
  "sub_total": 9000,
  "length": 10,
  "breadth": 15,
  "height": 20,
  "weight": 2.5
}'

ok, fine, just do it
Taifun

my problem is still there even after using the json body POST Request. i am getting error invalid data here is the response that i am getting from API.

{
  "message": "Oops! Invalid Data.",
  "errors": {
    "order_id": [
      "The order id field is required."
    ]
  },
  "status_code": 422
}

Here’s the Post Request Body i even valdiated it with Jsonvalidator as asked by taifun.

{
“order_id”: “4265”,
“order_date”: “2019-07-24 11:11”,
“pickup_location”: “Shop”,
“billing_customer_name”: “Naruto”,
“billing_last_name”: “Uzumaki”,
“billing_address”: “House 221B, Leaf Village”,
“billing_address_2”: “Near Hokage House”,
“billing_city”: “New Delhi”,
“billing_pincode”: “110002”,
“billing_state”: “Delhi”,
“billing_country”: “India”,
“billing_email”: “[email protected]”,
“billing_phone”: “9876543210”,
“shipping_is_billing”: true ,
“order_items”: [
{
“name”: “Kunai”,
“sku”: “chakra123”,
“units”: 10,
“selling_price”: “900”
}
],
“payment_method”: “Prepaid”,
“shipping_charges”: 0,
“sub_total”: 9000,
“length”: 10,
“breadth”: 15,
“height”: 20,
“weight”: 2.5
}

i have never faced a problem like this when using REST API on kodular please somebody help me.

here’s the block

Try changing the order number and see if it works cause I read in apidocs that…

“Orders cannot be created with order id’s same as that of cancelled orders. If error 422 shows up despite filling the correct details, consider changing the order_id.”