"Referer header must match host." when trying to use _find - http

I'm working with CouchDB and am trying to search a db using _find. I am currently running into the following error:
error: 'bad_request',
reason: 'Referer header must match host.',
scope: 'couch',
statusCode: 400,
request:
{ method: 'POST',
headers:
{ 'content-type': 'application/json',
accept: 'application/json',
Host: 'https://example.com',
Referer: 'https://example.com' },
uri: 'http://XXXXXX:XXXXXX#206.189.178.130:5984/gc_common/_find',
body: '{"selector":{"_id":"taglist"}}' },
headers:
{ date: 'Wed, 24 Jul 2019 01:58:37 GMT',
'content-type': 'application/json',
connection: 'close',
'cache-control': 'must-revalidate',
statusCode: 400,
uri: 'http://XXXXXX:XXXXXX#206.189.178.130:5984/gc_common/_find' },
errid: 'non_200',
description: 'couch returned 400' }

Related

IBM cloud deployment

I am facing this issue while deploying my model. I can not rectify this issue pls help m
WMLClientError: Publishing model failed.
Reason: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Date': 'Tue, 08 Nov 2022 13:04:55 GMT', 'Content-Type': 'application/json', 'Content-Length': '292', 'Connection': 'keep-alive', 'server-timing': 'intid;desc=6f623e2ef5e91f78, intid;desc=6f623e2ef5e91f78', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains', 'CF-Cache-Status': 'DYNAMIC', 'Server': 'cloudflare', 'CF-RAY': '766e84679bdde7b3-DFW'})
HTTP response body: {
"trace": "90db2fd42086ff741443abb0c688d8ad",
"errors": [{
"code": "invalid_request_entity",
"message": "Invalid request entity: Unsupported software specification 'default_py3.7'.",
"more_info": "https://cloud.ibm.com/apidocs/machine-learning"
}],
"status_code": "400"
}
I am facing this issue while deploying my model. I can not rectify this issue pls help me

Invalid patch error in Contentful CMA client

I am trying to populating an empty field by using patch method in Contentful. The following piece of code works in one cloned environment but does not work in another.
let patchData: OpPatch[] = [
{
op: 'replace',
path: '/fields/keywords',
value: entryKeyword,
},
];
await cmaClient.entry.patch({ entryId: entryId }, patchData, { 'X-Contentful-Version': entryVersion });
When I try to execute this, receiving a 'Unprocessable Entity' error:
UnprocessableEntity: {
"status": 422,
"statusText": "Unprocessable Entity",
"message": "Could not apply patch to entry: invalid patch",
"details": {},
"request": {
"url": "/spaces/xyz/environments/abc/entries/123456789",
"headers": {
"Accept": "application/json, text/plain, */*",
"Content-Type": "application/json-patch+json",
"X-Contentful-User-Agent": "sdk contentful-management-plain.js/7.54.2;",
"Authorization": "Bearer ...",
"user-agent": "node.js/v14.19.2",
"Accept-Encoding": "gzip",
"X-Contentful-Version": 25,
"Content-Length": 78
},
"method": "patch",
"payloadData": "[{\"op\":\"replace\",\"path\":\"/fields/keywords\",\"value\":\"test keyword\"}]"
},
"requestId": "abcd-123456"
}
I have the same exact access permissions to both environments. What am I missing out on?
I had the same issue - turned out when the entry doesn't have the filed you're trying to patch - it will throw an error like above.

“Only reserved document ids may start with underscore." when trying to use _find

I'm working with CouchDB and am trying to search a db using _find. I am currently running into the following error:
error: 'illegal_docid',
reason: 'Only reserved document ids may start with underscore.',
scope: 'couch',
statusCode: 400,
request:
{ method: 'POST',
headers:
{ 'content-type': 'application/json',
accept: 'application/json',
Host: 'example.com',
Referer: 'https://example.com' },
uri: 'http://XXXXXX:XXXXXX#206.189.178.130:5984/gc_common/_find',
body: '{"selector":{"_id":"taglist"}}' },
headers:
{ date: 'Thu, 25 Jul 2019 22:04:09 GMT',
'content-type': 'application/json',
connection: 'close',
'cache-control': 'must-revalidate',
statusCode: 400,
uri: 'http://XXXXXX:XXXXXX#206.189.178.130:5984/gc_common/_find' },
errid: 'non_200',
description: 'couch returned 400' }

Response is 404 when term matcher added on path of api on using pact-stub-server

describe('Getting asset for player', () => {
before(() => {
return provider.addInteraction({
given: 'GET call',
uponReceiving: 'Get asset for player',
withRequest: {
method: 'GET',
path: term({
matcher: '/api/assets/[0-9]+',
generate: '/api/assets/10006'
}),
},
willRespondWith: {
status: 200,
headers: { 'Content-Type': 'application/json' },
body: assetByPlayer
}
});
});
it('Get the asset by player', () => {
return request.get(`http://localhost:${PORT}/api/assets/10006`)
.set({ 'Accept': 'application/json' }).then((response) => {
return expect(Promise.resolve(response.statusCode)).to.eventually.equals(200);
}).catch(err => {
console.log("Error in asset with player listing", err);
});
});
});
I get the json file as : https://pastebin.com/TqRbTmNS
When i use the json file in other code base by pact stub server , it
gets the request from UI as
===> Received Request ( method: GET, path: /api/assets/10006, query:
None, headers: Some({"actasuserid": "5", "content-type": "application/vnd.nativ.mio.v1+json", "host": "masteraccount.local.nativ.tv:30044", "accept": "application/json", "authorization": "Basic bWFzdGVydXNlcjptYXN0ZXJ1c2Vy", "connection": "close", "content-length": "2"}), body: Present(2 bytes) )
but does not sends any response
But if i just remove the matching rules part
"matchingRules": {
"$.path": {
"match": "regex",
"regex": "\/api\/assets\/[0-9]+"
}
}
it starts to work again
===> Received Request ( method: GET, path: /api/assets/10006, query: None, headers: Some({"authorization": "Basic bWFzdGVydXNlcjptYXN0ZXJ1c2Vy", "accept": "application/json", "content-length": "2", "connection": "close", "host": "masteraccount.local.nativ.tv:30044", "content-type": "application/vnd.nativ.mio.v1+json", "actasuserid": "5"}), body: Present(2 bytes) )
<=== Sending Response ( status: 200, headers: Some({"Content-Type": "application/json"}), body: Present(4500 bytes) )
and I can see the data to be present
Could you let me what is wrong here ?

How to make meteor work with google apis?

please help me to make google apis and meteor work. So I set up accounts-ui accounts-password accounts-google. I took the needed scopes with my accounts-config.js
import { Accounts } from 'meteor/accounts-base'
Accounts.ui.config({requestPermissions: {
google: [
'https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/userinfo.profile',
'https://mail.google.com/',
'https://www.googleapis.com/auth/gmail.compose',
'https://www.googleapis.com/auth/gmail.insert',
'https://www.googleapis.com/auth/gmail.labels',
'https://www.googleapis.com/auth/gmail.metadata',
'https://www.googleapis.com/auth/gmail.modify',
'https://www.googleapis.com/auth/gmail.readonly',
'https://www.googleapis.com/auth/gmail.send',
'https://www.googleapis.com/auth/gmail.settings.basic',
'https://www.googleapis.com/auth/gmail.settings.sharing'
]
},
requestOfflineToken: {
google: true
}
})
On my server I have a method like this
import { Meteor } from 'meteor/meteor'
import { HTTP } from 'meteor/http'
Meteor.startup(() => {
// Meteor.call('createDraft')
Meteor.methods({
'createDraft': function () {
console.log(this.userId)
const user = Meteor.users.findOne(this.userId)
const email = user.services.google.email
console.log(email)
const dataObject = {
'message': {
'raw': CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse('Hello, World!'))
}
}
HTTP.post('https://www.googleapis.com/upload/gmail/v1/users/' + encodeURIComponent(email) + '/drafts', dataObject, (error, result) => {
if (error) {
console.log('err', error)
}
if (result) {
console.log('res', result)
}
})
}
})
})
On the client I have a component like this
import React, { Component } from 'react'
class Test extends Component {
createDraftClick () {
Meteor.call('createDraft', () => console.log('called createDraft'))
}
render () {
return (
<div className="btn btn-primary" onClick={this.createDraftClick.bind(this)}>Create Draft</div>
)
}
}
export default Test
When I click on it and my method is called I get the following response
err { [Error: failed [401] { "error": { "errors": [ { "domain": "global", "reason": "required", "message": "Login Required", "locationType": "header", "location": "Authorization" } ], "code": 401, "message": "Login Required" } } ]
I20161219-17:02:07.904(4)? response:
I20161219-17:02:07.904(4)? { statusCode: 401,
I20161219-17:02:07.905(4)? content: '{\n "error": {\n "errors": [\n {\n "domain": "global",\n "reason": "required",\n "message": "Login Required",\n "locationType": "header",\n "location": "Authorization"\n }\n ],\n "code": 401,\n "message": "Login Required"\n }\n}\n',
I20161219-17:02:07.907(4)? headers:
I20161219-17:02:07.908(4)? { 'x-guploader-uploadid': 'AEnB2UrTNWqenpV_aT_KKab8HA71eHYdc3t8pjIzo6e_JyW4OWz3fIopa6hVpCmDK5nTM0VE8z3UOam8bSNKQNatKjLHHN_zNPFLQl_9eet8VNXO-3yNBYU',
I20161219-17:02:07.908(4)? vary: 'Origin, X-Origin',
I20161219-17:02:07.913(4)? 'www-authenticate': 'Bearer realm="https://accounts.google.com/"',
I20161219-17:02:07.914(4)? 'content-type': 'application/json; charset=UTF-8',
I20161219-17:02:07.914(4)? 'content-length': '238',
I20161219-17:02:07.916(4)? date: 'Mon, 19 Dec 2016 13:02:07 GMT',
I20161219-17:02:07.917(4)? server: 'UploadServer',
I20161219-17:02:07.917(4)? 'alt-svc': 'quic=":443"; ma=2592000; v="35,34"',
I20161219-17:02:07.917(4)? connection: 'close' },
I20161219-17:02:07.919(4)? data: { error: [Object] } } }
I20161219-17:02:07.926(4)? res { statusCode: 401,
I20161219-17:02:07.926(4)? content: '{\n "error": {\n "errors": [\n {\n "domain": "global",\n "reason": "required",\n "message": "Login Required",\n "locationType": "header",\n "location": "Authorization"\n }\n ],\n "code": 401,\n "message": "Login Required"\n }\n}\n',
I20161219-17:02:07.926(4)? headers:
I20161219-17:02:07.928(4)? { 'x-guploader-uploadid': 'AEnB2UrTNWqenpV_aT_KKab8HA71eHYdc3t8pjIzo6e_JyW4OWz3fIopa6hVpCmDK5nTM0VE8z3UOam8bSNKQNatKjLHHN_zNPFLQl_9eet8VNXO-3yNBYU',
I20161219-17:02:07.928(4)? vary: 'Origin, X-Origin',
I20161219-17:02:07.929(4)? 'www-authenticate': 'Bearer realm="https://accounts.google.com/"',
I20161219-17:02:07.930(4)? 'content-type': 'application/json; charset=UTF-8',
I20161219-17:02:07.931(4)? 'content-length': '238',
I20161219-17:02:07.931(4)? date: 'Mon, 19 Dec 2016 13:02:07 GMT',
I20161219-17:02:07.932(4)? server: 'UploadServer',
I20161219-17:02:07.933(4)? 'alt-svc': 'quic=":443"; ma=2592000; v="35,34"',
I20161219-17:02:07.933(4)? connection: 'close' },
I20161219-17:02:07.933(4)? data: { error: { errors: [Object], code: 401, message: 'Login Required' } } }
But I am signed in with my google account. Why am I getting this error?
I also tried to use atmosphere package GoogleApi but I get the same error. Please help dear sirs. Thank you in advance.

Resources