API Keys related question

i will integrate in laravel 5.6 ship hero Every time every day API Key chnage?

Hi @bhavesh
Welcome to our community!

Are you referring to the token expiration? Getting Started – Developer Resources | ShipHero

Thanks in advance!
Tom

i read this document, please guide me on how to implement this API key for web development(PHP)?

Hi @bhavesh!
I’m not familiarized with PHP I apologize for that.

I did found this article on how to Post JSON data with PHP

And in case it helps we had another user working with PHP that posted on this thread

Thanks again!
Tom

CURLOPT_USERPWD => base64_encode($username.":".$password),

‘{ “username”: “YOUR EMAIL”,
“password”: “YOUR PASSWORD”
}’

which username and password should i required?
when i run this curl with url i got Response “username is required”
any Suggestion?

Hi @bhavesh!
You should use the same that when login on https://app.shiphero.com/dashboard

Let me know if that doesn’t work for you,
Thanks again!
Tom

Yes i am using that but not working.

You could test with a test endpoint, something like:

https://requestbin.com/

To verify what is being sent and if it’s as expected

$body = ‘mutation {
order_create(
data: {
order_number: “11223344”
shop_name: “ExampleShop”
fulfillment_status: “pending”
order_date: “2019-07-29”
total_tax: “29.00”
subtotal: “150.00”
total_discounts: “20.00”
total_price: “159.00”
shipping_lines: {
title: “UPS”
price: “0.00”
carrier: “UPS”
method: “Ground”
}
shipping_address: {
first_name: “John”
last_name: “Johnson”
company: “The Johnson Co”
address1: “2543 Duck St.”
address2: “Apt. 2”
city: “Oklahoma”
state: “Oklahoma”
state_code: “OK”
zip: “73008”
country: “US”
country_code: “US”
email: “johnjohnsonco@johnsonco.com
phone: “5555555555”
}
billing_address: {
first_name: “John”
last_name: “Johnson”
company: “The Johnson Co”
address1: “2543 Duck St.”
address2: “Apt. 2”
city: “Oklahoma”
state: “OK”
state_code: “OK”
zip: “73008”
country: “US”
country_code: “US”
email: “johnjohnsonco@johnsonco.com
phone: “5555555555”
}
line_items: {
sku: “testSKU12345”
partner_line_item_id: “282960815”
quantity: 2
price: “150.00”
product_name: “Example Product”
fulfillment_status: “pending”
quantity_pending_fulfillment: 2
warehouse_id: “V2FyZWhvdYNlOjgwNzU=”
}
required_ship_date: “2019-08-29”
}
)
}’;

    $username = 'xxx@lessgistics.com';
	$password = 'xxx456';

	//$credentials = base64_encode("$username:$password");

	$ch = curl_init();
	curl_setopt_array($ch, [
	  CURLOPT_URL=> "https://public-api.shiphero.com/graphql",
	  CURLOPT_RETURNTRANSFER => true,
	  CURLOPT_POST => true,
	  //CURLOPT_USERNAME => "sutharbhavesh1111@gmail.com", //"minipokemart@lessgistics.com", //
	  CURLOPT_POSTFIELDS => $body, // json_encode($order_to_ship), Created same as previous snippet
	  CURLOPT_USERPWD => base64_encode($username.":".$password), //"xxx@lessgistics.com:xxx456",
	  CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
	  CURLOPT_HTTPHEADER => [
	    'Content-Type: application/json',
	    'Accept: application/json',
	    'Cache-Control: no-cache',
	    'Username: sutharbhavesh1111@gmail.com',
	    'refresh_token: U30pkJp5imhPDpFua92V-8LmMdNpySrNZQcuBOYPzw5kM',
	    //'Authorization: Basic {$credentials}',
	    'access_token:a8866579e12304937b5b9b11811f940efa80d83d',
	    'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IlJUQXlOVU13T0Rrd09ETXhSVVZDUXpBNU5rSkVOVVUxUmtNeU1URTRNMEkzTWpnd05ERkdNdyJ9.eyJodHRwOi8vc2hpcGhlcm8tcHVibGljLWFwaS9hcHAiOnsibmFtZSI6IlNoaXBoZXJvIFB1YmxpYyBBUEkgR2F0ZXdheSIsImlkIjoibXRjYndxSTJyNjEzRGNPTjNEYlVhSExxUXpRNGRraG4iLCJkYXRhIjp7fX0sImh0dHA6Ly9zaGlwaGVyby1wdWJsaWMtYXBpL3VzZXJpbmZvIjp7Im5hbWUiOiJzdXRoYXJiaGF2ZXNoMTExMUBnbWFpbC5jb20iLCJuaWNrbmFtZSI6InN1dGhhcmJoYXZlc2gxMTExIiwicGljdHVyZSI6Imh0dHBzOi8vcy5ncmF2YXRhci5jb20vYXZhdGFyL2EzODMzYTE4ZmVmNWMzMDFmYzEyOTE0MGR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PL1fk0m7ku9F7CaevuBQdBQvAQR5UxbzgQpzr6nAOwGCCjBFuY4XPbMa1WOWxINNlUQ'
	  ],
	  CURLOPT_SSL_VERIFYPEER => true,
	  CURLOPT_SSL_VERIFYHOST => 0,
	]);

	
	$response = curl_exec($ch);
	//echo "<pre>";
	//print_r($response);
	var_dump($response);

	exit;

string(71) "{“message”: “Unexpected error. Please contact a system administrator.”}"

I get in this error now please any one can help me i am stuck in this code since last one week

Hi @bhavesh!
Could you share the request_id returned for that mutation?
If you try using an IDE such as Altair, does it work with that same payload?
Thanks in advance!
Tom

Bearer code is not working i think all perfect stepby step follow but not working
“error”: “Failed to fetch schema. Please check your connection”

Try adding the account query, something like this:

query {
  account {
    request_id
    complexity
    data {
      id
      legacy_id
    }
  }
}

And seeing if it returns something

same error display

“error”: “Failed to fetch. Please check your connection”

Connection error

How to get Warehouse id from query?

Hello!
This is the query you would use to get the warehouse id:

query{
  account{
    data{
      warehouses{
        id
      }
    }
  }
}

hello @tomasw @Theresa
Thank You for replay i have tested and there is working on “Altair GraphQLClient” Than after run this code on my file give me this Respons.
“message”: “Unexpected error. Please contact a system administrator.”}
Thanks in advance!
Bhavesh

Hi @bhavesh!
If you send both to Request Bin (Altair and your code) can you spot any difference between both?
Thanks again!
Tom

Hello @tomasw
No changes difference between both code
Thanks again!
Bhavesh

Thanks for confirming that @bhavesh!
Are you on a fulfillment account?
If that is the case it won’t work because those accounts don’t have warehouses, but you could try getting your warehouse ID from the following Query:

query{
  account{
    request_id
    complexity
    data{
          id
    legacy_id
    my_warehouse {
      id
    }
    }
  }
}

Is there any chance you could send us a request_id for when you try this on Altair and sends you the correct response back?
That way we can get your account details and investigate further.
Thanks again!
Tom

Thanks for guide to me @tomasw
order is working fine but i not find out this same question.

  1. How to get tracking number from order because i send a email in put this tracking number.
  2. Order date i will put but he automatically add yesterday date.
    please give me suggestion

Thanks again!
Bhavesh