pact-foundation / pact-ruby

Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
https://pact.io
MIT License
2.17k stars 216 forks source link

Failed to publish pact file to pact broker due to error":"Error parsing JSON #234

Closed YingzheHeBetty closed 3 years ago

YingzheHeBetty commented 3 years ago

I have a pact file generated by a consumer in ruby: { "consumer": { "name": "CMM" }, "provider": { "name": "Analytics Service" }, "interactions": [ { "description": "a get request for Delivery Sources Metadata Report", "request": { "method": "get", "path": "/v1/cloud_ingestion/agencies/4d32d0e0-b477-4d9b-96b5-efba8a6eb957/reports/metadata/delivery_sources", "query": "" }, "response": { "status": 200, "headers": { "Content-Type": "text/csv" } } }, { "description": "a get request for a wrong Metadata Report", "request": { "method": "get", "path": "/v1/cloud_ingestion/agencies/431584dd-635f-44b8-9180-950a6b071a40/reports/metadata/line_item", "query": "" }, "response": { "status": 404, "headers": {} } }, { "description": "a get request for Creatives Metadata Report", "request": { "method": "get", "path": "/v1/cloud_ingestion/agencies/6e059492-58a0-405d-8850-7db0dcc1e228/reports/metadata/creatives", "query": "" }, "response": { "status": 200, "headers": { "Content-Type": "text/csv" } } }, { "description": "a get request for LineItem Metadata Report", "request": { "method": "get", "path": "/v1/cloud_ingestion/agencies/d35ad058-c859-420d-b869-02472c761feb/reports/metadata/line_items", "query": "" }, "response": { "status": 200, "headers": { "Content-Type": "text/csv" } } }, { "description": "a get request for Creatives Daily Delivery Report", "request": { "method": "get", "path": "/v1/cloud_ingestion/agencies/b1b92b3e-5273-4ac4-ba4b-9b8c40e5d452/reports/daily_delivery/creatives", "query": "startDate=2017-06-12&endDate=2017-06-18", "matchingRules": { "$.query.startDate[0]": { "match": "regex", "regex": "^\\d{4}-[01]\\d-[0-3]\\d$" }, "$.query.endDate[0]": { "match": "regex", "regex": "^\\d{4}-[01]\\d-[0-3]\\d$" } } }, "response": { "status": 200, "headers": { "Content-Type": "text/csv" } } } ], "metadata": { "pactSpecification": { "version": "2.0.0" } } }

when publishing it to the pact broker using HTTP request: curl -v -XPUT -H “Content-Type: application/json” -d@spec/pacts/cmm-analytics_service.json \https://pact-broker.prod.ourcentro.net:443/pacts/provider/Analytics%20Service/consumer/CMM/version/1.0.0

I got an error:

`< HTTP/1.1 400 Bad Request
< Date: Thu, 14 Jan 2021 20:22:54 GMT
< Content-Type: application/hal+json;charset=utf-8
< Content-Length: 60
< Connection: keep-alive
< Vary: Accept
< Server: Webmachine-Ruby/1.5.0 Rack/1.3
< X-Pact-Broker-Version: 2.57.0
< X-Content-Type-Options: nosniff
* HTTP error before end of send, stop sending
< 
* Closing connection 1
* TLSv1.2 (OUT), TLS alert, Client hello (1):
{"error":"Error parsing JSON - 783: unexpected token at ''"}`