Error Status 400 When Uploading to Youtube API v3 - post

I keep getting an error when trying to POST to Youtube v3 API.
I'm trying to get a response URI, so I can upload a Youtube video.
This is the documentation I'm referencing: https://developers.google.com/youtube/v3/docs/videos/insert#go
Does anyone know what I'm doing wrong? Error log is below.
My code:
axios({
method: 'POST',
baseURL: 'https://www.googleapis.com',
url: '/upload/youtube/v3/videos',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Content-Length': 167,
'X-Upload-Content-Length': 302080,
'X-Upload-Content-Type': 'video/mp4',
'Authorization': `Bearer <MY_ACCESS_TOKEN>`, // has my actual access_token
},
params: {
'uploadType': 'resumable',
'key': <MY_API_KEY>, // has my actual app API key
'part': 'snippet,status'
},
data: {
'snippet': {
'title': 'Test Upload 1',
'description': 'Test Description 1',
'tags': ['tag1', 'tag2'],
},
'status': {
'privacyStatus': 'private',
}
}
})
.then(response => {
res.json(response.data);
})
.catch(err => console.log(err));
Error Log:
Error: Request failed with status code 400
at createError (/mnt/e/Dev/20200316_youtube_api/node_modules/axios/lib/core/createError.js:16:15)
at settle (/mnt/e/Dev/20200316_youtube_api/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/mnt/e/Dev/20200316_youtube_api/node_modules/axios/lib/adapters/http.js:236:11)
at IncomingMessage.emit (events.js:323:22)
at endReadableNT (_stream_readable.js:1204:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
config: {
url: '/upload/youtube/v3/videos',
method: 'post',
params: {
key: '<MY_API_KEY>',
part: 'snippet,status'
},
data: '{"snippet":{"title":"Test Upload 1","description":"Test Description 1","tags":["tag1","tag2"]},"status":{"privacyStatus":"private"}}',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
'Content-Length': 132,
'X-Upload-Content-Length': 302080,
'X-Upload-Content-Type': 'video/mp4',
Authorization: 'Bearer <MY_ACCESS_TOKEN>',
'User-Agent': 'axios/0.19.2'
},
baseURL: 'https://www.googleapis.com',
transformRequest: [ [Function: transformRequest] ],
transformResponse: [ [Function: transformResponse] ],
timeout: 0,
adapter: [Function: httpAdapter],
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
validateStatus: [Function: validateStatus]
},
request: ClientRequest {
_events: [Object: null prototype] {
socket: [Function],
abort: [Function],
aborted: [Function],
error: [Function],
timeout: [Function],
prefinish: [Function: requestOnPrefinish]
},
_eventsCount: 6,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: null,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket: TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: 'www.googleapis.com',
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object: null prototype],
_eventsCount: 9,
connecting: false,
_hadError: false,
_parent: null,
_host: 'www.googleapis.com',
_readableState: [ReadableState],
readable: true,
_maxListeners: undefined,
_writableState: [WritableState],
writable: false,
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: [TLSWrap],
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: [Circular],
[Symbol(res)]: [TLSWrap],
[Symbol(asyncId)]: 6,
[Symbol(kHandle)]: [TLSWrap],
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: null,
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(kCapture)]: false,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 0,
[Symbol(connect-options)]: [Object]
},
connection: TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: 'www.googleapis.com',
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object: null prototype],
_eventsCount: 9,
connecting: false,
_hadError: false,
_parent: null,
_host: 'www.googleapis.com',
_readableState: [ReadableState],
readable: true,
_maxListeners: undefined,
_writableState: [WritableState],
writable: false,
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: [TLSWrap],
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: [Circular],
[Symbol(res)]: [TLSWrap],
[Symbol(asyncId)]: 6,
[Symbol(kHandle)]: [TLSWrap],
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: null,
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(kCapture)]: false,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 0,
[Symbol(connect-options)]: [Object]
},
_header: 'POST /upload/youtube/v3/videos?key=<MY_API_KEY>&part=snippet,status HTTP/1.1\r\n' +
'Accept: application/json\r\n' +
'Content-Type: application/json\r\n' +
'Content-Length: 132\r\n' +
'X-Upload-Content-Length: 302080\r\n' +
'X-Upload-Content-Type: video/mp4\r\n' +
'Authorization: Bearer <MY_ACCESS_TOKEN>\r\n' +
'User-Agent: axios/0.19.2\r\n' +
'Host: www.googleapis.com\r\n' +
'Connection: close\r\n' +
'\r\n',
_onPendingData: [Function: noopPendingOutput],
agent: Agent {
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
defaultPort: 443,
protocol: 'https:',
options: [Object],
requests: {},
sockets: [Object],
freeSockets: {},
keepAliveMsecs: 1000,
keepAlive: false,
maxSockets: Infinity,
maxFreeSockets: 256,
maxCachedSessions: 100,
_sessionCache: [Object],
[Symbol(kCapture)]: false
},
socketPath: undefined,
method: 'POST',
insecureHTTPParser: undefined,
path: '/upload/youtube/v3/videos?key=<MY_API_KEY>&part=snippet,status',
_ended: true,
res: IncomingMessage {
_readableState: [ReadableState],
readable: false,
_events: [Object: null prototype],
_eventsCount: 3,
_maxListeners: undefined,
socket: [TLSSocket],
connection: [TLSSocket],
httpVersionMajor: 1,
httpVersionMinor: 1,
httpVersion: '1.1',
complete: true,
headers: [Object],
rawHeaders: [Array],
trailers: {},
rawTrailers: [],
aborted: false,
upgrade: false,
url: '',
method: null,
statusCode: 400,
statusMessage: 'Bad Request',
client: [TLSSocket],
_consuming: false,
_dumped: false,
req: [Circular],
responseUrl: 'https://www.googleapis.com/upload/youtube/v3/videos?key=<MY_API_KEY>&part=snippet,status',
redirects: [],
[Symbol(kCapture)]: false
},
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
_redirectable: Writable {
_writableState: [WritableState],
writable: true,
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
_options: [Object],
_redirectCount: 0,
_redirects: [],
_requestBodyLength: 132,
_requestBodyBuffers: [],
_onNativeResponse: [Function],
_currentRequest: [Circular],
_currentUrl: 'https://www.googleapis.com/upload/youtube/v3/videos?key=<MY_API_KEY>&part=snippet,status',
[Symbol(kCapture)]: false
},
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype] {
accept: [Array],
'content-type': [Array],
'content-length': [Array],
'x-upload-content-length': [Array],
'x-upload-content-type': [Array],
authorization: [Array],
'user-agent': [Array],
host: [Array]
}
},
response: {
status: 400,
statusText: 'Bad Request',
headers: {
'x-guploader-uploadid': '<REPONSE_ID_THAT_I_REMOVED>',
vary: 'Origin, X-Origin',
'content-type': 'application/json; charset=UTF-8',
'content-length': '353',
date: 'Sun, 07 Jun 2020 22:45:50 GMT',
server: 'UploadServer',
'alt-svc': 'h3-27=":443"; ma=2592000,h3-25=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q049=":443";
ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"',
connection: 'close'
},
config: {
url: '/upload/youtube/v3/videos',
method: 'post',
params: [Object],
data: '{"snippet":{"title":"Test Upload 1","description":"Test Description 1","tags":["tag1","tag2"]},"status":{"privacyStatus":"private"}}',
headers: [Object],
baseURL: 'https://www.googleapis.com',
transformRequest: [Array],
transformResponse: [Array],
timeout: 0,
adapter: [Function: httpAdapter],
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
validateStatus: [Function: validateStatus]
},
request: ClientRequest {
_events: [Object: null prototype],
_eventsCount: 6,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: null,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket: [TLSSocket],
connection: [TLSSocket],
_header: 'POST /upload/youtube/v3/videos?key=<MY_API_KEY>&part=snippet,status HTTP/1.1\r\n' +
'Accept: application/json\r\n' +
'Content-Type: application/json\r\n' +
'Content-Length: 132\r\n' +
'X-Upload-Content-Length: 302080\r\n' +
'X-Upload-Content-Type: video/mp4\r\n' +
'Authorization: Bearer <MY_ACCESS_TOKEN>\r\n' +
'User-Agent: axios/0.19.2\r\n' +
'Host: www.googleapis.com\r\n' +
'Connection: close\r\n' +
'\r\n',
_onPendingData: [Function: noopPendingOutput],
agent: [Agent],
socketPath: undefined,
method: 'POST',
insecureHTTPParser: undefined,
path: '/upload/youtube/v3/videos?key=<MY_API_KEY>&part=snippet,status',
_ended: true,
res: [IncomingMessage],
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
_redirectable: [Writable],
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype]
},
data: { error: [Object] }
},
isAxiosError: true,
toJSON: [Function]
}

That request is not for uploading video, that request returns a url to which the video can be uploaded.

Related

Next.js getServerSideProps is not working using docker

Currently, I am trying to fetch data after communicating with the backend server through SSR through Next.js and sprinkle it on the page.
However, one problem is that when I run npm run dev locally, getServerSideProps runs well, but when I upload it to a container through Docker-compose, my API for getServerSideProps doesn't work.
const ResultMenu: NextPage<Props> = ({ CategoryData }) => {
...
};
export default ResultMenu;
export const getServerSideProps: GetServerSideProps = async (context) => {
try {
const { menuId } = context.query;
const response = await axios.get<CategoryType[]>(
"http://localhost:8080/category/get/menu",
{
headers: {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*",
},
params: {
menuId: menuId,
},
}
);
const data = response.data;
console.log(data);
return {
props: {
CategoryData: data,
},
};
} catch (err) {
console.log(err);
return {
props: {},
};
}
};
In the frontend container, this error code appears
Error: connect ECONNREFUSED 127.0.0.1:8080
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1195:16) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 8080,
config: {
transitional: {
silentJSONParsing: true,
forcedJSONParsing: true,
clarifyTimeoutError: false
},
adapter: [Function: httpAdapter],
transformRequest: [ [Function: transformRequest] ],
transformResponse: [ [Function: transformResponse] ],
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
validateStatus: [Function: validateStatus],
headers: {
Accept: 'application/json, text/plain, */*',
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
'User-Agent': 'axios/0.26.1'
},
params: { menuId: '1' },
method: 'get',
url: 'http://localhost:8080/category/get/menu',
data: undefined
},
request: <ref *1> Writable {
_writableState: WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: false,
needDrain: false,
ending: false,
ended: false,
finished: false,
destroyed: false,
decodeStrings: true,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: true,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
afterWriteTickInfo: null,
buffered: [],
bufferedIndex: 0,
allBuffers: true,
allNoop: true,
pendingcb: 0,
constructed: true,
prefinished: false,
errorEmitted: false,
emitClose: true,
autoDestroy: true,
errored: null,
closed: false,
closeEmitted: false,
[Symbol(kOnFinished)]: []
},
_events: [Object: null prototype] {
response: [Function: handleResponse],
error: [Function: handleRequestError],
socket: [Function: handleRequestSocket]
},
_eventsCount: 3,
_maxListeners: undefined,
_options: {
maxRedirects: 21,
maxBodyLength: 10485760,
protocol: 'http:',
path: '/category/get/menu?menuId=1',
method: 'GET',
headers: [Object],
agent: undefined,
agents: [Object],
auth: undefined,
hostname: 'localhost',
port: '8080',
nativeProtocols: [Object],
pathname: '/category/get/menu',
search: '?menuId=1'
},
_ended: true,
_ending: true,
_redirectCount: 0,
_redirects: [],
_requestBodyLength: 0,
_requestBodyBuffers: [],
_onNativeResponse: [Function (anonymous)],
_currentRequest: ClientRequest {
_events: [Object: null prototype],
_eventsCount: 7,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: false,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
maxRequestsOnConnectionReached: false,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: false,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: 0,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
_closed: false,
socket: [Socket],
_header: 'GET /category/get/menu?menuId=1 HTTP/1.1\r\n' +
'Accept: application/json, text/plain, */*\r\n' +
'Content-Type: application/json\r\n' +
'Access-Control-Allow-Origin: *\r\n' +
'User-Agent: axios/0.26.1\r\n' +
'Host: localhost:8080\r\n' +
'Connection: close\r\n' +
'\r\n',
_keepAliveTimeout: 0,
_onPendingData: [Function: nop],
agent: [Agent],
socketPath: undefined,
method: 'GET',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
path: '/category/get/menu?menuId=1',
_ended: false,
res: null,
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: 'localhost',
protocol: 'http:',
_redirectable: [Circular *1],
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype]
},
_currentUrl: 'http://localhost:8080/category/get/menu?menuId=1',
[Symbol(kCapture)]: false
},
response: undefined,
isAxiosError: true,
toJSON: [Function: toJSON]
}
1
undefined
Dockerfile
FROM node:12
ENV PORT 3000
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Installing dependencies
COPY package*.json /usr/src/app/
RUN npm install
# Copying source files
COPY . /usr/src/app
# Building app
RUN npm run build
EXPOSE 3000
# Running the app
CMD "npm" "run" "dev"
docker-compose.yml
version: "3"
services:
frontend:
container_name: frontend
build:
context: ./frontend
dockerfile: Dockerfile
ports:
- "3000:3000"
volumes:
- ./frontend:/usr/src/app
- /usr/src/app/node_modules
- /usr/src/app/.next
networks:
- network-tier
backend:
container_name: backend
build: ./backend
depends_on:
- mysqldb
ports:
- 8080:8080
environment:
spring.datasource.url: "jdbc:mysql://mysqldb:3306/test_db?useSSL=false&useLegacyDatetimeCode=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul&characterEncoding=UTF-8&autoReconnect=true&createDatabaseIfNotExist=true"
volumes:
- ./menu-canvas:/usr/src/backend
networks:
- network-tier
tty: true
mysqldb:
image: mysql:5.7
container_name: mysqldb
environment:
MYSQL_DATABASE: test_db
MYSQL_ROOT_PASSWORD: "0000"
MYSQL_ROOT_HOST: "%"
CHARACTER_SET_SERVER: utf8
command:
[
"--character-set-server=utf8mb4",
"--collation-server=utf8mb4_unicode_ci",
]
volumes:
- ./menu-canvas:/usr/src/db
ports:
- "3306:3306"
networks:
- network-tier
platform: linux/amd64
networks:
network-tier:
external: true
volumes:
menu-canvas:
next.config.js
/** #type {import('next').NextConfig} */
const nextConfig = {
images: {
domains: ["localhost", "*"],
},
reactStrictMode: true,
};
module.exports = nextConfig;
package.json
{
"name": "frontend",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
...
},
"devDependencies": {
...
},
"proxy": {
"*": {
"target": "http://localhost:8080"
}
}
}
I've been thinking a lot all day, but I don't know how... Help!
When running the getServerSideProps the communication would be container to container. So for these requests, routes to localhost would not work. Instead it would need to be something like backend:8080 (when communicating from the frontend service to the backend service).
The localhost domain would work as expected on the client side requests assuming you were exposing all ports as expected.
When you run this without docker everything works because all services are on localhost. When run via docker-compose they no longer are.
If you really wanted to use localhost instead of the service name you may be able to use a network host https://docs.docker.com/network/host/

Request failed with status code 403 (Specific to Walmart API)

This is specific to the walmart api. I feel as though I configured the headers accurately and provided the required headers as they asked according to the documentation. However, I still get a 403 error. When I tested in postman, I still got a 403 error and it mentioned that the server was refusing a valid request. Here is the logged data below. I used Node.js on the backend with axios and crypto-js libraries. Can anyone let me know what is wrong here? Please let me know if there is anything else I should add to the question. (I purposely removed the consumer ID value):
Starting Walmart API call...
[0] Error: Request failed with status code 403
[0] at createError (C:\Projects\node_modules\axios\lib\core\createError.js:16:15)
[0] at settle (C:\Projects\node_modules\axios\lib\core\settle.js:17:12)
[0] at Unzip.handleStreamEnd (C:\Projects\node_modules\axios\lib\adapters\http.js:260:11)
[0] at Unzip.emit (events.js:400:28)
[0] at Unzip.emit (domain.js:470:12)
[0] at endReadableNT (internal/streams/readable.js:1317:12)
[0] at processTicksAndRejections (internal/process/task_queues.js:82:21) {
[0] config: {
[0] url: 'https://developer.api.walmart.com/api-proxy/service/affil/product/v2/paginated/items',
[0] method: 'get',
[0] headers: {
[0] Accept: 'application/json, text/plain, */*',
[0] 'WM_SEC.KEY_VERSION': '1',
[0] 'WM_SEC.TIMESTAMP': '1630376129289',
[0] 'WM_SEC.AUTH_SIGNATURE': [Promise],
[0] 'WM_CONSUMER.ID': '',
[0] 'User-Agent': 'axios/0.21.1'
[0] },
[0] transformRequest: [ [Function: transformRequest] ],
[0] transformResponse: [ [Function: transformResponse] ],
[0] timeout: 0,
[0] adapter: [Function: httpAdapter],
[0] xsrfCookieName: 'XSRF-TOKEN',
[0] xsrfHeaderName: 'X-XSRF-TOKEN',
[0] maxContentLength: -1,
[0] maxBodyLength: -1,
[0] validateStatus: [Function: validateStatus],
[0] data: undefined
[0] },
[0] request: <ref *1> ClientRequest {
[0] _events: [Object: null prototype] {
[0] abort: [Function (anonymous)],
[0] aborted: [Function (anonymous)],
[0] connect: [Function (anonymous)],
[0] error: [Function (anonymous)],
[0] socket: [Function (anonymous)],
[0] timeout: [Function (anonymous)],
[0] prefinish: [Function: requestOnPrefinish]
[0] },
[0] _eventsCount: 7,
[0] _maxListeners: undefined,
[0] outputData: [],
[0] outputSize: 0,
[0] writable: true,
[0] destroyed: true,
[0] _last: true,
[0] chunkedEncoding: false,
[0] shouldKeepAlive: false,
[0] _defaultKeepAlive: true,
[0] useChunkedEncodingByDefault: false,
[0] sendDate: false,
[0] _removedConnection: false,
[0] _removedContLen: false,
[0] _removedTE: false,
[0] _contentLength: 0,
[0] _hasBody: true,
[0] _trailer: '',
[0] finished: true,
[0] _headerSent: true,
[0] socket: TLSSocket {
[0] _tlsOptions: [Object],
[0] _secureEstablished: true,
[0] _securePending: false,
[0] _newSessionPending: false,
[0] _controlReleased: true,
[0] secureConnecting: false,
[0] _SNICallback: null,
[0] servername: 'developer.api.walmart.com',
[0] alpnProtocol: false,
[0] authorized: true,
[0] authorizationError: null,
[0] encrypted: true,
[0] _events: [Object: null prototype],
[0] _eventsCount: 12,
[0] connecting: false,
[0] _hadError: false,
[0] _parent: null,
[0] _host: 'developer.api.walmart.com',
[0] _readableState: [ReadableState],
[0] _maxListeners: undefined,
[0] _writableState: [WritableState],
[0] allowHalfOpen: false,
[0] _sockname: null,
[0] _pendingData: null,
[0] _pendingEncoding: '',
[0] server: undefined,
[0] _server: null,
[0] ssl: null,
[0] _requestCert: true,
[0] _rejectUnauthorized: true,
[0] parser: null,
[0] _httpMessage: [Circular *1],
[0] write: [Function: writeAfterFIN],
[0] [Symbol(res)]: null,
[0] [Symbol(verified)]: true,
[0] [Symbol(pendingSession)]: null,
[0] [Symbol(async_id_symbol)]: 124,
[0] [Symbol(kHandle)]: null,
[0] [Symbol(kSetNoDelay)]: false,
[0] [Symbol(lastWriteQueueSize)]: 0,
[0] [Symbol(timeout)]: null,
[0] [Symbol(kBuffer)]: null,
[0] [Symbol(kBufferCb)]: null,
[0] [Symbol(kBufferGen)]: null,
[0] [Symbol(kCapture)]: false,
[0] [Symbol(kBytesRead)]: 715,
[0] [Symbol(kBytesWritten)]: 340,
[0] [Symbol(connect-options)]: [Object],
[0] [Symbol(RequestTimeout)]: undefined
[0] },
[0] _header: 'GET /api-proxy/service/affil/product/v2/paginated/items HTTP/1.1\r\n' +
[0] 'Accept: application/json, text/plain, */*\r\n' +
[0] 'WM_SEC.KEY_VERSION: 1\r\n' +
[0] 'WM_SEC.TIMESTAMP: 1630376129289\r\n' +
[0] 'WM_SEC.AUTH_SIGNATURE: [object Promise]\r\n' +
[0] 'WM_CONSUMER.ID: ...\r\n' +
[0] 'User-Agent: axios/0.21.1\r\n' +
[0] 'Host: developer.api.walmart.com\r\n' +
[0] 'Connection: close\r\n' +
[0] '\r\n',
[0] _keepAliveTimeout: 0,
[0] _onPendingData: [Function: noopPendingOutput],
[0] agent: Agent {
[0] _events: [Object: null prototype],
[0] _eventsCount: 2,
[0] _maxListeners: undefined,
[0] defaultPort: 443,
[0] protocol: 'https:',
[0] options: [Object],
[0] requests: {},
[0] sockets: {},
[0] freeSockets: {},
[0] keepAliveMsecs: 1000,
[0] keepAlive: false,
[0] maxSockets: Infinity,
[0] maxFreeSockets: 256,
[0] scheduling: 'lifo',
[0] maxTotalSockets: Infinity,
[0] totalSocketCount: 0,
[0] maxCachedSessions: 100,
[0] _sessionCache: [Object],
[0] [Symbol(kCapture)]: false
[0] },
[0] socketPath: undefined,
[0] method: 'GET',
[0] maxHeaderSize: undefined,
[0] insecureHTTPParser: undefined,
[0] path: '/api-proxy/service/affil/product/v2/paginated/items',
[0] _ended: true,
[0] res: IncomingMessage {
[0] _readableState: [ReadableState],
[0] _events: [Object: null prototype],
[0] _eventsCount: 1,
[0] _maxListeners: undefined,
[0] socket: [TLSSocket],
[0] httpVersionMajor: 1,
[0] httpVersionMinor: 1,
[0] httpVersion: '1.1',
[0] complete: true,
[0] headers: [Object],
[0] rawHeaders: [Array],
[0] trailers: {},
[0] rawTrailers: [],
[0] aborted: false,
[0] upgrade: false,
[0] url: '',
[0] method: null,
[0] statusCode: 403,
[0] statusMessage: 'Forbidden',
[0] client: [TLSSocket],
[0] _consuming: true,
[0] _dumped: false,
[0] req: [Circular *1],
[0] responseUrl: 'https://developer.api.walmart.com/api-proxy/service/affil/product/v2/paginated/items',
[0] redirects: [],
[0] [Symbol(kCapture)]: false,
[0] [Symbol(RequestTimeout)]: undefined
[0] },
[0] aborted: false,
[0] timeoutCb: null,
[0] upgradeOrConnect: false,
[0] parser: null,
[0] maxHeadersCount: null,
[0] reusedSocket: false,
[0] host: 'developer.api.walmart.com',
[0] protocol: 'https:',
[0] _redirectable: Writable {
[0] _writableState: [WritableState],
[0] _events: [Object: null prototype],
[0] _eventsCount: 2,
[0] _maxListeners: undefined,
[0] _options: [Object],
[0] _ended: true,
[0] _ending: true,
[0] _redirectCount: 0,
[0] _redirects: [],
[0] _requestBodyLength: 0,
[0] _requestBodyBuffers: [],
[0] _onNativeResponse: [Function (anonymous)],
[0] _currentRequest: [Circular *1],
[0] _currentUrl: 'https://developer.api.walmart.com/api-proxy/service/affil/product/v2/paginated/items',
[0] [Symbol(kCapture)]: false
[0] },
[0] [Symbol(kCapture)]: false,
[0] [Symbol(kNeedDrain)]: false,
[0] [Symbol(corked)]: 0,
[0] [Symbol(kOutHeaders)]: [Object: null prototype] {
[0] accept: [Array],
[0] 'wm_sec.key_version': [Array],
[0] 'wm_sec.timestamp': [Array],
[0] 'wm_sec.auth_signature': [Array],
[0] 'wm_consumer.id': [Array],
[0] 'user-agent': [Array],
[0] host: [Array]
[0] }
[0] },
[0] response: {
[0] status: 403,
[0] statusText: 'Forbidden',
[0] headers: {
[0] 'content-type': 'application/json;charset=utf-8',
[0] 'last-modified': 'Tue, 31 Aug 2021 02:18:31 GMT',
[0] 'strict-transport-security': 'max-age=86400',
[0] 'wm_svc.env': 'prod',
[0] 'wm_svc.name': 'affil-product',
[0] 'wm_svc.version': '2.0.0',
[0] 'x-lua-strict-transport-security': 'max-age=86400',
[0] 'x-tb': '1',
[0] 'x-tb-optimization-total-bytes-saved': '0',
[0] date: 'Tue, 31 Aug 2021 02:18:31 GMT',
[0] connection: 'close',
[0] 'set-cookie': [Array]
[0] },
[0] config: {
[0] url: 'https://developer.api.walmart.com/api-proxy/service/affil/product/v2/paginated/items',
[0] method: 'get',
[0] headers: [Object],
[0] transformRequest: [Array],
[0] transformResponse: [Array],
[0] timeout: 0,
[0] adapter: [Function: httpAdapter],
[0] xsrfCookieName: 'XSRF-TOKEN',
[0] xsrfHeaderName: 'X-XSRF-TOKEN',
[0] maxContentLength: -1,
[0] maxBodyLength: -1,
[0] validateStatus: [Function: validateStatus],
[0] data: undefined
[0] },
[0] request: <ref *1> ClientRequest {
[0] _events: [Object: null prototype],
[0] _eventsCount: 7,
[0] _maxListeners: undefined,
[0] outputData: [],
[0] outputSize: 0,
[0] writable: true,
[0] destroyed: true,
[0] _last: true,
[0] chunkedEncoding: false,
[0] shouldKeepAlive: false,
[0] _defaultKeepAlive: true,
[0] useChunkedEncodingByDefault: false,
[0] sendDate: false,
[0] _removedConnection: false,
[0] _removedContLen: false,
[0] _removedTE: false,
[0] _contentLength: 0,
[0] _hasBody: true,
[0] _trailer: '',
[0] finished: true,
[0] _headerSent: true,
[0] socket: [TLSSocket],
[0] _header: 'GET /api-proxy/service/affil/product/v2/paginated/items HTTP/1.1\r\n' +
[0] 'Accept: application/json, text/plain, */*\r\n' +
[0] 'WM_SEC.KEY_VERSION: 1\r\n' +
[0] 'WM_SEC.TIMESTAMP: 1630376129289\r\n' +
[0] 'WM_SEC.AUTH_SIGNATURE: [object Promise]\r\n' +
[0] 'WM_CONSUMER.ID: 0ea59601-ea5c-448b-9003-d1baea61e4d6\r\n' +
[0] 'User-Agent: axios/0.21.1\r\n' +
[0] 'Host: developer.api.walmart.com\r\n' +
[0] 'Connection: close\r\n' +
[0] '\r\n',
[0] _keepAliveTimeout: 0,
[0] _onPendingData: [Function: noopPendingOutput],
[0] agent: [Agent],
[0] socketPath: undefined,
[0] method: 'GET',
[0] maxHeaderSize: undefined,
[0] insecureHTTPParser: undefined,
[0] path: '/api-proxy/service/affil/product/v2/paginated/items',
[0] _ended: true,
[0] res: [IncomingMessage],
[0] aborted: false,
[0] timeoutCb: null,
[0] upgradeOrConnect: false,
[0] parser: null,
[0] maxHeadersCount: null,
[0] reusedSocket: false,
[0] host: 'developer.api.walmart.com',
[0] protocol: 'https:',
[0] _redirectable: [Writable],
[0] [Symbol(kCapture)]: false,
[0] [Symbol(kNeedDrain)]: false,
[0] [Symbol(corked)]: 0,
[0] [Symbol(kOutHeaders)]: [Object: null prototype]
[0] },
[0] data: { details: [Object] }
[0] },
[0] isAxiosError: true,
[0] toJSON: [Function: toJSON]

Outlook REST API returns events without start and end dates

When requesting GET https://outlook.office.com/api/v2.0/me/calendars/{calendar_id}/events the response (for some events) does not have a Start and End date.
The full structure for such events is as follows:
{
'OriginalStartTimeZone': None,
'End': {
'TimeZone': 'tzone://Microsoft/Utc',
'DateTime': '0001-01-01T00:00:00.0000000Z'
},
'HasAttachments': False,
'ResponseRequested': True,
'ShowAs': 'Free',
'Recurrence': None,
'Start': {
'TimeZone': 'tzone://Microsoft/Utc',
'DateTime': '0001-01-01T00:00:00.0000000Z'
},
'BodyPreview': '',
'AllowNewTimeProposals': True,
'Location': {...},
'Attendees': [...],
'TransactionId': None,
'Type': 'SingleInstance',
'ResponseStatus': {
'Response': 'NotResponded',
'Time': '0001-01-01T00:00:00Z'
},
'Body': {...},
'OnlineMeeting': None,
'IsRoomRequested': False,
'OnlineMeetingProvider': 'Unknown',
'IsCancelled': False,
'IsAllDay': False,
'ReminderMinutesBeforeStart': 0,
'Subject': '...',
'Categories': [],
'LastModifiedDateTime': '2020-03-11T18:31:15.548Z',
'AutoRoomBookingOptions': None,
'OriginalEndTimeZone': None,
'CreatedDateTime': '2020-03-11T18:34:34.259429Z',
'IsOnlineMeeting': False,
'#odata.id': '...',
'IsDraft': False,
'WebLink': '...',
'ChangeKey': '...',
'SeriesMasterId': None,
'IsOrganizer': True,
'iCalUId': None,
'AutoRoomBookingStatus': 'None',
'Locations': [],
'Id': '...',
'IsReminderOn': False,
'Calendar#odata.associationLink': '...',
'Calendar#odata.navigationLink': '...',
'Importance': 'Normal',
'Organizer': {...},
'#odata.etag': '...',
'Sensitivity': 'Normal',
'OnlineMeetingUrl': None
}
Is this normal behavior? If so, how can this be displayed?
How can I create such an event to reproduce it?

Microsoft Graph API OneNote pages content BadRequest

I am using OneNote /content endpoint to retrieve page content as described here: https://learn.microsoft.com/en-us/graph/api/page-get?view=graph-rest-1.0
However, calling GET on /me/onenote/pages/{id}/content[?includeIDs=true] returns me this:
{
"error": {
"code": "BadRequest",
"message": "Resource not found for the segment 'content['.",
"innerError": {
"request-id": "6b7e5549-32a5-4b6f-80ed-ecacp9v41699",
"date": "2020-03-31T00:05:27"
}
}
}
calling GET on /me/onenote/pages/{id}/content returns this:
{
"_readableState": {
"objectMode": false,
"highWaterMark": 16384,
"buffer": {
"head": null,
"tail": null,
"length": 0
},
"length": 0,
"pipes": [],
"flowing": null,
"ended": false,
"endEmitted": false,
"reading": false,
"sync": false,
"needReadable": false,
"emittedReadable": false,
"readableListening": false,
"resumeScheduled": false,
"errorEmitted": false,
"emitClose": true,
"autoDestroy": false,
"destroyed": false,
"defaultEncoding": "utf8",
"awaitDrainWriters": null,
"multiAwaitDrain": false,
"readingMore": false,
"decoder": null,
"encoding": null
},
"readable": true,
"_events": {},
"_eventsCount": 5,
"_writableState": {
"objectMode": false,
"highWaterMark": 16384,
"finalCalled": false,
"needDrain": false,
"ending": false,
"ended": false,
"finished": false,
"destroyed": false,
"decodeStrings": true,
"defaultEncoding": "utf8",
"length": 0,
"writing": false,
"corked": 0,
"sync": true,
"bufferProcessing": false,
"writecb": null,
"writelen": 0,
"afterWriteTickInfo": null,
"bufferedRequest": null,
"lastBufferedRequest": null,
"pendingcb": 0,
"prefinished": false,
"errorEmitted": false,
"emitClose": true,
"autoDestroy": false,
"errored": false,
"bufferedRequestCount": 0,
"corkedRequestsFree": {
"next": null,
"entry": null
}
},
"writable": true,
"allowHalfOpen": true,
"_transformState": {
"needTransform": false,
"transforming": false,
"writecb": null,
"writechunk": null,
"writeencoding": null
}
}
Neither returns the actual page content. Any idea?
The "includeIDs" is an optional query parameter. Remove the square brackets around it to get rid of the Bad Request error. So the request should be GET on /me/onenote/pages/{id}/content?includeIDs=true

InvalidTransition from Youtube Live Streaming API

I got good result for Broadcast
&youtube.LiveBroadcastListResponse{
Etag: "\"aaa-3cgQ/bbb\"",
EventId: "",
Items: {
&youtube.LiveBroadcast{
ContentDetails: &youtube.LiveBroadcastContentDetails{
BoundStreamId: "ccc-ddd",
BoundStreamLastUpdateTimeMs: "2017-01-30T09:02:38.977Z",
ClosedCaptionsType: "closedCaptionsDisabled",
EnableClosedCaptions: false,
EnableContentEncryption: true,
EnableDvr: true,
EnableEmbed: true,
EnableLowLatency: false,
MonitorStream: &youtube.MonitorStreamInfo{
BroadcastStreamDelayMs: 1,
EmbedHtml: "<iframe width=\"425\" height=\"344\" src=\"https://www.youtube.com/embed/eee?autoplay=1&livemonitor=1\" frameborder=\"0\" allowfullscreen></iframe>",
EnableMonitorStream: true,
ForceSendFields: nil,
NullFields: nil,
},
Projection: "rectangular",
RecordFromStart: true,
StartWithSlate: true,
ForceSendFields: nil,
NullFields: nil,
},
Etag: "\"aaa-3cgQ/fff\"",
Id: "eee",
Kind: "youtube#liveBroadcast",
Snippet: &youtube.LiveBroadcastSnippet{
ActualEndTime: "",
ActualStartTime: "",
ChannelId: "UCccc-ggg",
Description: "",
IsDefaultBroadcast: false,
LiveChatId: "Cg0KC0hfUkFFaW4zUUVJ",
PublishedAt: "2017-01-30T04:59:19.000Z",
ScheduledEndTime: "2017-01-31T02:00:00.000Z",
ScheduledStartTime: "2017-01-31T00:00:00.000Z",
Thumbnails: &youtube.ThumbnailDetails{
Default: &youtube.Thumbnail{
Height: 90,
Url: "https://i.ytimg.com/vi/eee/default_live.jpg",
Width: 120,
ForceSendFields: nil,
NullFields: nil,
},
High: &youtube.Thumbnail{
Height: 360,
Url: "https://i.ytimg.com/vi/eee/hqdefault_live.jpg",
Width: 480,
ForceSendFields: nil,
NullFields: nil,
},
Maxres: (*youtube.Thumbnail)(nil),
Medium: &youtube.Thumbnail{
Height: 180,
Url: "https://i.ytimg.com/vi/eee/mqdefault_live.jpg",
Width: 320,
ForceSendFields: nil,
NullFields: nil,
},
Standard: (*youtube.Thumbnail)(nil),
ForceSendFields: nil,
NullFields: nil,
},
Title: "Test broadcast from iOS",
ForceSendFields: nil,
NullFields: nil,
},
Statistics: (*youtube.LiveBroadcastStatistics)(nil),
Status: &youtube.LiveBroadcastStatus{
LifeCycleStatus: "ready",
LiveBroadcastPriority: "",
PrivacyStatus: "unlisted",
RecordingStatus: "notRecording",
ForceSendFields: nil,
NullFields: nil,
},
TopicDetails: (*youtube.LiveBroadcastTopicDetails)(nil),
ServerResponse: googleapi.ServerResponse{},
ForceSendFields: nil,
NullFields: nil,
},
},
Kind: "youtube#liveBroadcastListResponse",
NextPageToken: "",
PageInfo: &youtube.PageInfo{
ResultsPerPage: 5,
TotalResults: 0,
ForceSendFields: nil,
NullFields: nil,
},
PrevPageToken: "",
TokenPagination: (*youtube.TokenPagination)(nil),
VisitorId: "",
ServerResponse: googleapi.ServerResponse{
HTTPStatusCode: 200,
Header: {
"Server": {"GSE"},
"Expires": {"Mon, 30 Jan 2017 11:34:04 GMT"},
"Date": {"Mon, 30 Jan 2017 11:34:04 GMT"},
"Cache-Control": {"private, max-age=0, must-revalidate, no-transform"},
"Etag": {"\"aaa-3cgQ/bbb\""},
"Vary": {"Origin", "X-Origin"},
"Content-Type": {"application/json; charset=UTF-8"},
"X-Frame-Options": {"SAMEORIGIN"},
"X-Content-Type-Options": {"nosniff"},
"X-Xss-Protection": {"1; mode=block"},
"Content-Length": {"1989"},
"Alt-Svc": {"quic=\":443\"; ma=2592000; v=\"35,34\""},
},
},
ForceSendFields: nil,
NullFields: nil,
}
And also good response for Stream:
&youtube.LiveStreamListResponse{
Etag: "\"aaa-3cgQ/iii-Sg\"",
EventId: "",
Items: {
&youtube.LiveStream{
Cdn: &youtube.CdnSettings{
Format: "360p",
FrameRate: "30fps",
IngestionInfo: &youtube.IngestionInfo{
BackupIngestionAddress: "rtmp://b.rtmp.youtube.com/live2?backup=1",
IngestionAddress: "rtmp://a.rtmp.youtube.com/live2",
StreamName: "3zjv-0cp2-wtet-0779",
ForceSendFields: nil,
NullFields: nil,
},
IngestionType: "rtmp",
Resolution: "360p",
ForceSendFields: nil,
NullFields: nil,
},
ContentDetails: (*youtube.LiveStreamContentDetails)(nil),
Etag: "\"aaa-3cgQ/hhh\"",
Id: "ccc-ddd",
Kind: "youtube#liveStream",
Snippet: &youtube.LiveStreamSnippet{
ChannelId: "UCccc-ggg",
Description: "",
IsDefaultStream: false,
PublishedAt: "2017-01-30T09:02:39.000Z",
Title: "Broadcast: eee App: 16 ID: 16",
ForceSendFields: nil,
NullFields: nil,
},
Status: &youtube.LiveStreamStatus{
HealthStatus: &youtube.LiveStreamHealthStatus{
ConfigurationIssues: nil,
LastUpdateTimeSeconds: 0x0,
Status: "good",
ForceSendFields: nil,
NullFields: nil,
},
StreamStatus: "active",
ForceSendFields: nil,
NullFields: nil,
},
ServerResponse: googleapi.ServerResponse{},
ForceSendFields: nil,
NullFields: nil,
},
},
Kind: "youtube#liveStreamListResponse",
NextPageToken: "",
PageInfo: &youtube.PageInfo{
ResultsPerPage: 5,
TotalResults: 0,
ForceSendFields: nil,
NullFields: nil,
},
PrevPageToken: "",
TokenPagination: (*youtube.TokenPagination)(nil),
VisitorId: "",
ServerResponse: googleapi.ServerResponse{
HTTPStatusCode: 200,
Header: {
"Date": {"Mon, 30 Jan 2017 11:35:54 GMT"},
"X-Frame-Options": {"SAMEORIGIN"},
"X-Xss-Protection": {"1; mode=block"},
"Content-Length": {"1008"},
"Content-Type": {"application/json; charset=UTF-8"},
"X-Content-Type-Options": {"nosniff"},
"Server": {"GSE"},
"Alt-Svc": {"quic=\":443\"; ma=2592000; v=\"35,34\""},
"Expires": {"Mon, 30 Jan 2017 11:35:54 GMT"},
"Cache-Control": {"private, max-age=0, must-revalidate, no-transform"},
"Etag": {"\"aaa-3cgQ/iii-Sg\""},
"Vary": {"Origin", "X-Origin"},
},
},
ForceSendFields: nil,
NullFields: nil,
}
But when I tried to transition to testing for eee, it shows an error:
&googleapi.Error{
Code: 403,
Message: "Invalid transition",
Body: "{\n \"error\": {\n \"errors\": [\n {\n \"domain\": \"youtube.liveBroadcast\",\n \"reason\": \"invalidTransition\",\n \"message\": \"Invalid transition\",\n \"extendedHelp\": \"https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/transition#params\"\n }\n ],\n \"code\": 403,\n \"message\": \"Invalid transition\"\n }\n}\n",
Header: {},
Errors: {
{Reason:"invalidTransition", Message:"Invalid transition"},
},
}
From the doc, it said that: The live broadcast can't transition from its current status to the requested status., that is from ready to testing, The stream status is already active and health is good, is there anything I missed?
Apparently it's caused by the stream resolution is too low, the camera is 360x640 (vertical >__<), creating new stream with 720p resolution solves this problem.

Resources