opensea-js icon indicating copy to clipboard operation
opensea-js copied to clipboard

Error: API Error 400: You cannot access body after reading from request's data stream

Open henry1jin opened this issue 4 years ago • 64 comments

When calling openseaSDK.createSellOrder, getting this error and not sure why.

henry1jin avatar Jun 15 '22 06:06 henry1jin

That link is looking mighty phishy.

henry1jin avatar Jun 15 '22 18:06 henry1jin

getting the same error when calling createBuyOrder

davidseroussi avatar Jun 15 '22 22:06 davidseroussi

Just deleted the bot comment, sorry about that.

Can you send over specific steps so I can reproduce? Also, is this happening for both sellOrder and buyOrder?

esteban-OpenSea avatar Jun 16 '22 17:06 esteban-OpenSea

Hi @esteban-OpenSea,

I've also noticed this as well. Here is an example request:

curl https://testnets-api.opensea.io/api/v2/orders/rinkeby/seaport/offers -X POST --data-raw '{"parameters":{"offerer":"0xd5E4EC33d198c57598BE0CA5e78772a4098A2cF6","zone":"0x9b814233894cd227f561b78cc65891aa55c62ad2","zoneHash":"0x3000000000000000000000000000000000000000000000000000000000000000","startTime":"1655418624","endTime":"1655505024","orderType":0,"offer":[{"itemType":1,"token":"0xc778417e063141139fce010982780140aa0cd5ab","identifierOrCriteria":"0","startAmount":"1000000000000000","endAmount":"1000000000000000"}],"consideration":[{"itemType":2,"token":"0xb74bf94049d2c01f8805b8b15db0909168cabf46","identifierOrCriteria":"271","startAmount":"1","endAmount":"1","recipient":"0xd5E4EC33d198c57598BE0CA5e78772a4098A2cF6"},{"itemType":1,"token":"0xc778417e063141139fce010982780140aa0cd5ab","identifierOrCriteria":"0","startAmount":"25000000000000","endAmount":"25000000000000","recipient":"0x0000000000000000000000000000000000000000"}],"totalOriginalConsiderationItems":2,"salt":"0x84d51b5b68c414392f80eeb33c0b6ab4","conduitKey":"0x0000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f0000","counter":0},"signature":"0x538492d5ab4f260190e6a819b329d731d869e81ebac6aae35aecd1bd5bd83181479cdec7fb059af83f3b8cd9bd2751c6e526b865beedb8d3ad5e334345734296"}' -H 'X-API-KEY: <api_key>'

{"errors":["You cannot access body after reading from request's data stream"]}%

plondon avatar Jun 16 '22 23:06 plondon

It's actually because of the url. In the repo, the basePath is https://api.opensea.io/api/v2/ but it should be https://api.opensea.io/v2/. So the final url is https://api.opensea.io/v2/orders/ethereum/seaport/offers

davidseroussi avatar Jun 16 '22 23:06 davidseroussi

Do you need to call testnets-api if the network is rinkeby?

plondon avatar Jun 17 '22 00:06 plondon

yes it would be https://testnets-api.opensea.io/v2/orders/rinkeby/seaport/offers

davidseroussi avatar Jun 17 '22 00:06 davidseroussi

@davidseroussi I think both urls should work actually. Would you mind posting a successful request with the order data?

plondon avatar Jun 17 '22 17:06 plondon

@plondon sure, this payload returned
{ "errors": [ "You cannot access body after reading from request's data stream" ] }
using /api/v2/offers, but returned the successful order using /v2/offers

{
		"parameters": {
			"offerer": "0xb040d6f5Ea06FBdB221004C1F5a8885D98EBdEa3",
			"offer": [{
				"itemType": 1,
				"token": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
				"identifierOrCriteria": 0,
				"startAmount": 100000000000000000,
				"endAmount": 100000000000000000
			}],
			"consideration": [{
				"itemType": 2,
				"token": "0x0Cfb5d82BE2b949e8fa73A656dF91821E2aD99FD",
				"identifierOrCriteria": 281479271686476,
				"startAmount": 1,
				"endAmount": 1,
				"recipient": "0xb040d6f5Ea06FBdB221004C1F5a8885D98EBdEa3"
			}, {
				"itemType": 1,
				"token": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
				"identifierOrCriteria": 0,
				"startAmount": 2500000000000000,
				"endAmount": 2500000000000000,
				"recipient": "0x8De9C5A032463C561423387a9648c5C7BCC5BC90"
			}, {
				"itemType": 1,
				"token": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
				"identifierOrCriteria": 0,
				"startAmount": 5000000000000000,
				"endAmount": 5000000000000000,
				"recipient": "0x8fda7f45b1427F2d4444F4c6D44D2B5d1cb46b53"
			}],
			"startTime": 0,
			"endTime": 1655574606,
			"orderType": 2,
			"zone": "0x004C00500000aD104D7DBd00e3ae0A5C00560C00",
			"zoneHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
			"salt": 89054825639822128,
			"conduitKey": "0x0000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f0000",
			"totalOriginalConsiderationItems": 3,
			"counter": 0
		},
		"signature": "0x0b13752edae09a827c32381561a4709b8defa7789209d66276ef9889f9fd730867cb167c56c27b823af61db3b11810f9d103d26e225e106062ed21907525ae7b1c"
	}

davidseroussi avatar Jun 17 '22 17:06 davidseroussi

This issue seems to be specific to the testnets-api, where the error returned is always

{"errors":["You cannot access body after reading from request's data stream"]}%

For mainnet, errors are coming through correctly

plondon avatar Jun 17 '22 20:06 plondon

This seems to be working for me, I am running the url you all are running: https://testnets-api.opensea.io/v2/orders/rinkeby/seaport/offers

It returns a successful call.

esteban-OpenSea avatar Jun 17 '22 21:06 esteban-OpenSea

@esteban-OpenSea thanks for the response, could you include the full curl?

plondon avatar Jun 17 '22 23:06 plondon

Same error here using: https://testnets-api.opensea.io/v2/orders/rinkeby/seaport/offers

douglasmoraisdev avatar Jun 18 '22 01:06 douglasmoraisdev

The /orders seaport APIs endpoints are simply not working, at least for the rinkeby network. I face the same error for createSellOrder.

The error is due to a bad handling of the user request data in Opensea's API django backend. It seems pretty easy to solve this error IMO.

Also, the docs are outdated and quite confusing: endpoints differ between docs and the SDK (api/v2 in SDK and v2 in docs). They also put /ethereum in the endpoint path for the rinkeby doc examples. The order parameters format in the docs is wrong.

As a user, I expect better guidance and/or support given how seaport is currently advertised as a functional protocol.

gqoew avatar Jun 18 '22 10:06 gqoew

curl --request POST
--url https://testnets-api.opensea.io/v2/orders/rinkeby/seaport/listings
--header 'Accept: application/json'
--header 'Content-Type: application/json'
--header 'X-API-KEY: 2f6f419a083c46de9d83ce3dbe7db601'
--data ' { "order_parameters": { "offerer": "0x45fe652136DB9a4BAC7A51B97217E16380e3C4F9", "zone": "0x9b814233894cd227f561b78cc65891aa55c62ad2", "zoneHash": "0x3000000000000000000000000000000000000000000000000000000000000000", "startTime": "1655538402", "endTime": "1656143201", "orderType": 0, "offer": [ { "itemType": 2, "token": "0xf5769f5d59e52363ac24fdd4781659430374cbb1", "identifierOrCriteria": "63", "startAmount": "1", "endAmount": "1" } ], "consideration": [ { "itemType": 0, "token": "0x0000000000000000000000000000000000000000", "identifierOrCriteria": "0", "startAmount": "1950000000000000", "endAmount": "1950000000000000", "recipient": "0x45fe652136DB9a4BAC7A51B97217E16380e3C4F9" }, { "itemType": 0, "token": "0x0000000000000000000000000000000000000000", "identifierOrCriteria": "0", "startAmount": "50000000000000", "endAmount": "50000000000000", "recipient": "0x8de9c5a032463c561423387a9648c5c7bcc5bc90" } ], "totalOriginalConsiderationItems": 2, "salt": "0x38d239ca430328b9cd02423b2942a68f", "conduitKey": "0x0000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f0000", "counter": 0 }, "signature": "0x98b65e071d2c002d769d4a5a98073824a34e85232f5e094b9f8108a43c5d2b1957438185209a1e8de8a13d3de89278adfa06e3effa5890049801c21a097884ed" } '

{"errors":["You cannot access body after reading from request's data stream"]}

casey-cindex avatar Jun 18 '22 12:06 casey-cindex

Reproduced with mainnet API: image

      seaport = new OpenSeaPort(app.provider, {
        networkName: Network.Main,
        apiKey: process.env.OPENSEA_APIKEY,
      })

const params = ...

await seaport.createSellOrder(params)

Error appears after signing.

app.provider is window.ethereum.

opensea-js version 4.0.1 and 4.0.2

Benjythebee avatar Jun 20 '22 01:06 Benjythebee

I'm getting the same error on rinkeby and mainnet. I echo the same sentiment as @gqoew, the docs are wrong and confusing--fields are labeled using snake_case, but the sdk uses camelCase. The create listing doc model for parameters does not express how to put an array for considerations and offer. The sdk also works differently than the doc. I'm confused and need dev support.

stewart-lore avatar Jun 20 '22 19:06 stewart-lore

I'm also running into the same issues - please help!

Thanks

mehranhydary avatar Jun 20 '22 22:06 mehranhydary

In Rinkeby, I change the URL manually to https://testnets-api.opensea.io/v2/orders/rinkeby/seaport/listings it changes to return CORS error now.

chenji23 avatar Jun 20 '22 22:06 chenji23

Wanted to provide an update-- I got sells working with a few changes:

  1. Updating the POST listing url to https://api.opensea.io/v2/orders/ethereum/seaport/listings remove the /api path segment.
  2. Updating to latest opensea-js and seaport-js which include updated Fee payout addresses.
  3. Adding restrictedByZone: true and allowPartialFills: false to the seaport call seaport.createOrder({...}). Thanks to @plondon for this.

It's worth pointing out that I'm actually listing on chain, without a signature, from a smart contract wallet so I'm using seaport.validate() and then posting the completed order to the corrected listings api using a signature from a different EOA account.

stewart-lore avatar Jun 20 '22 23:06 stewart-lore