Discussion Forum: Thread 342136

 Author: JeLi View Messages Posted By JeLi
 Posted: Jul 1, 2023 04:25
 Subject: API - postman
 Viewed: 102 times
 Topic: Technical Issues
Cancel Message
Cancel
Reply to Message
Reply
BrickLink
ID Card

JeLi (45)

Location:  Belgium, Flemish Brabant
Member Since Contact Type Status
Mar 10, 2023 Contact Member Seller
Buying Privileges - OKSelling Privileges - OK
Store: JeLi Bricks
Hi all,
I am trying to get the API to work, but I am struggling
I have a proper connection in my vb.net code, f.e. to get the price guide for
a part.
But when trying to add parameters (f.e. the new_or_used=U) my request fails.

I tried searching the forum over here and found the postman app to test the API
calls.

Do you guys have any information to set this up?
- I created a new file and added a sample URL
- Authorization tab:
* type = OAuth1.0
* add authorization data = request headers
* signature method = HMAC-SHA1
* consumerkey/consumer secret/access token/token secret correctly set
But I keep getting 401/bad_oauth_request
I assume I need to add the timestamp and nonce, but I don't see how to add
this without proper calculations??

Any1 who can help me to set this up, so I can try to figure out my original problem
myself (or help me with the parameters is also fine ofc )
 Author: hedgehog_bricks View Messages Posted By hedgehog_bricks
 Posted: Jul 1, 2023 18:04
 Subject: Re: API - postman
 Viewed: 44 times
 Topic: Technical Issues
Cancel Message
Cancel
Reply to Message
Reply
BrickLink
ID Card

hedgehog_bricks (1858)

Location:  United Kingdom, England
Member Since Contact Type Status
Nov 29, 2008 Member Does Not Allow Contact Seller
Buying Privileges - OKSelling Privileges - OK
Store Closed Store: Hedgehog Bricks
In Technical Issues, JeLi writes:
  Hi all,
I am trying to get the API to work, but I am struggling
I have a proper connection in my vb.net code, f.e. to get the price guide for
a part.
But when trying to add parameters (f.e. the new_or_used=U) my request fails.

I tried searching the forum over here and found the postman app to test the API
calls.

This is a valid request for price guide info that uses the new_and_used parameter:

https://api.bricklink.com/api/store/v1/items/PART/76959/price?color_id=1&guide_type=stock&new_or_used=N&vat=N


  Any1 who can help me to set this up, so I can try to figure out my original problem
myself (or help me with the parameters is also fine ofc )


This works for me with Postman:

GET https://api.bricklink.com/api/store/v1/orders

In the Authorization tab:
Type: OAuth 1.0
Add authorization data to: Request headers
Signature Method: HMAC-SHA1
Consumer Key: Your BL consumer key "ConsumerKey"
Consumer Secret: Your BL consumer secret "ConsumerSecret"
Access Token: Your BL access token value "TokenValue"
Token Secret: Your BL access token secret "TokenSecret"

Postman should handle the timestamp, nonce and signature as they are part of
the OAuth 1.0 standard.

Double check that you're using the correct access token values for your current
IP address (I have a fixed IP address to make this easier).

Hope that helps!

Jonathan
 Author: JeLi View Messages Posted By JeLi
 Posted: Jul 2, 2023 19:14
 Subject: Re: API - postman
 Viewed: 31 times
 Topic: Technical Issues
Cancel Message
Cancel
Reply to Message
Reply
BrickLink
ID Card

JeLi (45)

Location:  Belgium, Flemish Brabant
Member Since Contact Type Status
Mar 10, 2023 Contact Member Seller
Buying Privileges - OKSelling Privileges - OK
Store: JeLi Bricks
In Technical Issues, hedgehog_bricks writes:
  In Technical Issues, JeLi writes:
  Hi all,
I am trying to get the API to work, but I am struggling
I have a proper connection in my vb.net code, f.e. to get the price guide for
a part.
But when trying to add parameters (f.e. the new_or_used=U) my request fails.

I tried searching the forum over here and found the postman app to test the API
calls.

This is a valid request for price guide info that uses the new_and_used parameter:

https://api.bricklink.com/api/store/v1/items/PART/76959/price?color_id=1&guide_type=stock&new_or_used=N&vat=N



I will check it out asap, thx in advance!

  
  Any1 who can help me to set this up, so I can try to figure out my original problem
myself (or help me with the parameters is also fine ofc )


This works for me with Postman:

GET https://api.bricklink.com/api/store/v1/orders

In the Authorization tab:
Type: OAuth 1.0
Add authorization data to: Request headers
Signature Method: HMAC-SHA1
Consumer Key: Your BL consumer key "ConsumerKey"
Consumer Secret: Your BL consumer secret "ConsumerSecret"
Access Token: Your BL access token value "TokenValue"
Token Secret: Your BL access token secret "TokenSecret"

Postman should handle the timestamp, nonce and signature as they are part of
the OAuth 1.0 standard.

Double check that you're using the correct access token values for your current
IP address (I have a fixed IP address to make this easier).

Hope that helps!

Jonathan

I verified all of them, but keep getting the 401.. I notice I forgot to add the
description in my original post: Version rejected: invalid OAuth parameters.
Maybe this is clearer for some1..
I use my authorization parameters also in my vb.net program, and they work fine.
 Author: JeLi View Messages Posted By JeLi
 Posted: Jul 2, 2023 19:55
 Subject: Re: API - postman
 Viewed: 36 times
 Topic: Technical Issues
Cancel Message
Cancel
Reply to Message
Reply
BrickLink
ID Card

JeLi (45)

Location:  Belgium, Flemish Brabant
Member Since Contact Type Status
Mar 10, 2023 Contact Member Seller
Buying Privileges - OKSelling Privileges - OK
Store: JeLi Bricks
In Technical Issues, JeLi writes:
  In Technical Issues, hedgehog_bricks writes:
  In Technical Issues, JeLi writes:
  Hi all,
I am trying to get the API to work, but I am struggling
I have a proper connection in my vb.net code, f.e. to get the price guide for
a part.
But when trying to add parameters (f.e. the new_or_used=U) my request fails.

I tried searching the forum over here and found the postman app to test the API
calls.

This is a valid request for price guide info that uses the new_and_used parameter:

https://api.bricklink.com/api/store/v1/items/PART/76959/price?color_id=1&guide_type=stock&new_or_used=N&vat=N



I will check it out asap, thx in advance!


Although I need some sleep I couldn't resist

If I run: https://api.bricklink.com/api/store/v1/items/part/76959/price
everything is working fine

If I run: https://api.bricklink.com/api/store/v1/items/part/76959/price?color_id=1&guide_type=stock&new_or_used=N&vat=N
I got the 401 - signature invalid


  
  
  Any1 who can help me to set this up, so I can try to figure out my original problem
myself (or help me with the parameters is also fine ofc )


This works for me with Postman:

GET https://api.bricklink.com/api/store/v1/orders

In the Authorization tab:
Type: OAuth 1.0
Add authorization data to: Request headers
Signature Method: HMAC-SHA1
Consumer Key: Your BL consumer key "ConsumerKey"
Consumer Secret: Your BL consumer secret "ConsumerSecret"
Access Token: Your BL access token value "TokenValue"
Token Secret: Your BL access token secret "TokenSecret"

Postman should handle the timestamp, nonce and signature as they are part of
the OAuth 1.0 standard.

Double check that you're using the correct access token values for your current
IP address (I have a fixed IP address to make this easier).

Hope that helps!

Jonathan

I verified all of them, but keep getting the 401.. I notice I forgot to add the
description in my original post: Version rejected: invalid OAuth parameters.
Maybe this is clearer for some1..
I use my authorization parameters also in my vb.net program, and they work fine.
 Author: KnC_Bricks View Messages Posted By KnC_Bricks
 Posted: Aug 2, 2023 14:52
 Subject: Re: API - postman
 Viewed: 52 times
 Topic: Technical Issues
Cancel Message
Cancel
Reply to Message
Reply
BrickLink
ID Card

KnC_Bricks (363)

Location:  USA, Montana
Member Since Contact Type Status
Jun 23, 2020 Contact Member Seller
Buying Privileges - OKSelling Privileges - OK
Store: KnC Bricks
In Technical Issues, JeLi writes:
  In Technical Issues, JeLi writes:
  In Technical Issues, hedgehog_bricks writes:
  In Technical Issues, JeLi writes:
  Hi all,
I am trying to get the API to work, but I am struggling
I have a proper connection in my vb.net code, f.e. to get the price guide for
a part.
But when trying to add parameters (f.e. the new_or_used=U) my request fails.

I tried searching the forum over here and found the postman app to test the API
calls.

This is a valid request for price guide info that uses the new_and_used parameter:

https://api.bricklink.com/api/store/v1/items/PART/76959/price?color_id=1&guide_type=stock&new_or_used=N&vat=N





  
  I will check it out asap, thx in advance!


Although I need some sleep I couldn't resist

If I run: https://api.bricklink.com/api/store/v1/items/part/76959/price
everything is working fine

If I run: https://api.bricklink.com/api/store/v1/items/part/76959/price?color_id=1&guide_type=stock&new_or_used=N&vat=N
I got the 401 - signature invalid


  
  
  Any1 who can help me to set this up, so I can try to figure out my original problem
myself (or help me with the parameters is also fine ofc )


This works for me with Postman:

GET https://api.bricklink.com/api/store/v1/orders

In the Authorization tab:
Type: OAuth 1.0
Add authorization data to: Request headers
Signature Method: HMAC-SHA1
Consumer Key: Your BL consumer key "ConsumerKey"
Consumer Secret: Your BL consumer secret "ConsumerSecret"
Access Token: Your BL access token value "TokenValue"
Token Secret: Your BL access token secret "TokenSecret"

Postman should handle the timestamp, nonce and signature as they are part of
the OAuth 1.0 standard.

Double check that you're using the correct access token values for your current
IP address (I have a fixed IP address to make this easier).

Hope that helps!

Jonathan

I verified all of them, but keep getting the 401.. I notice I forgot to add the
description in my original post: Version rejected: invalid OAuth parameters.
Maybe this is clearer for some1..
I use my authorization parameters also in my vb.net program, and they work fine.




I found an issue a while back when writing vbcode for Google sheets.
I was getting the same error,but only on some specific API calls. If the utl
that is used to generate the signature has a '?', you need to replace
the '&' between the url and the parameters with a '%26'. All
other '&' need to be replaced with '%3F'.

Here is a chunk of my code:
// create the HMAC key by combining the consumer secret and token secret
const hmacKey = `${ConsumerSecret}&${TokenSecret}`;
//console.log(`hmacKey: ${hmacKey}`);

// create the signature base string by combining the method, URL, and parameters
// not sure why this is %26 and not '&'
// 'orders?filed=false' needs a %26
// 'orders/21839620' needs a &

if (url.includes('?' ) ) {
var signatureBaseString = `${method}&${encodeURIComponent(url,)}%26${encodeURIComponent(params)}`;
} else {
var signatureBaseString = `${method}&${encodeURIComponent(url,)}&${encodeURIComponent(params)}`;

}

signatureBaseString = signatureBaseString.replace('%3F', '&'
);
//console.log(`base string: ${signatureBaseString}`);

Hope this helps.