我想使用节点模块request复制此Postman呼叫。查看屏幕截图。
如屏幕截图所示,在我的请求中,我需要传递一个bearer token
和x-www-form-urlencoded
值。我尝试遵循此SO post的前2个答案,但均未成功。
我基本上已经尝试过
let form = {
"field1": value1,
"filed2": value2
};
let headers = {
'Content-Type' : 'application/x-www-form-urlencoded',
'Authorization': 'Bearer ' + token
}
request.post({ url: "https://myapp.net/myendpoint", form: form, headers: headers }, function(err, res, success){
console.log(success);
});
还有
let form = {
"field1": value1,
"field2": value2
};
var formData = querystring.stringify(form);
let options = {
uri: "https://myapp.net/myendpoint",
method: 'POST',
auth: {
'bearer': token
},
headers: {
'Content-Type' : 'application/x-www-form-urlencoded'
},
body: formData
};
request.post(options, function(err, res, success){
console.log(success);
});
有人可以显示出正确的方法吗?
编辑:
澄清一下:这些请求的结果是400状态。如果我发送form-data
,我也会在Postman上获得400,但是如果我发送x-www-form-urlencoded
,它将在Postman中成功。我不知道如何在请求中做到这一点。
答案 0 :(得分:0)
尝试一下
checking for -Werror=unknown-warning-option... no
Failed commandline was:
--------------------------------------------------
/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc conftest.c -Wall -I. -I$(SRCPATH) --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -march=armv5te -msoft-float -D__ANDROID__ -D__ARM_ARCH_5TE__ -D__ARM_ARCH_5TEJ__ -Werror=unknown-warning-option --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -nostdlib -o conftest
cc1: error: -Werror=unknown-warning-option: no option -Wunknown-warning-option
--------------------------------------------------
Failed program was:
--------------------------------------------------
int main (void) { return 0; }
--------------------------------------------------
x264 configure script
Command line options: "--prefix=/Users/Project/bishe/x264/libs/armeabi-v7a" "--host=arm-linux" "--sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm" "--cross-prefix=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-" "--extra-cflags=-march=armv5te" "-msoft-float" "-D__ANDROID__" "-D__ARM_ARCH_5TE__" "-D__ARM_ARCH_5TEJ__" "--extra-ldflags=-nostdlib" "--enable-pic" "--enable-static" "--enable-strip" "--disable-cli" "--disable-asm" "--disable-win32thread" "--disable-avs" "--disable-swscale" "--disable-lavf" "--disable-ffms" "--disable-gpac" "--disable-lsmash" "--disable-opencl"
checking whether /Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc works... yes
checking whether /Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc supports for( int i = 0; i < 9; i++ ); with -std=gnu99... yes
checking for pthread_create(0,0,0,0); in pthread.h... no
Failed commandline was:
--------------------------------------------------
/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc conftest.c -Wall -I. -I$(SRCPATH) --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -march=armv5te -msoft-float -D__ANDROID__ -D__ARM_ARCH_5TE__ -D__ARM_ARCH_5TEJ__ -std=gnu99 -D_GNU_SOURCE -lpthread --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -nostdlib -lm -o conftest
conftest.c:1:21: fatal error: pthread.h: No such file or directory
#include <pthread.h>
^
compilation terminated.
--------------------------------------------------
Failed program was:
--------------------------------------------------
#include <pthread.h>
int main (void) { pthread_create(0,0,0,0); return 0; }
--------------------------------------------------
checking for pthread_create(0,0,0,0); in pthread.h... no
Failed commandline was:
--------------------------------------------------
/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc conftest.c -Wall -I. -I$(SRCPATH) --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -march=armv5te -msoft-float -D__ANDROID__ -D__ARM_ARCH_5TE__ -D__ARM_ARCH_5TEJ__ -std=gnu99 -D_GNU_SOURCE --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -nostdlib -lm -o conftest
conftest.c:1:21: fatal error: pthread.h: No such file or directory
#include <pthread.h>
^
compilation terminated.
--------------------------------------------------
Failed program was:
--------------------------------------------------
#include <pthread.h>
int main (void) { pthread_create(0,0,0,0); return 0; }
--------------------------------------------------
checking for log2f(2); in math.h... no
Failed commandline was:
--------------------------------------------------
/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc conftest.c -Wall -I. -I$(SRCPATH) --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -march=armv5te -msoft-float -D__ANDROID__ -D__ARM_ARCH_5TE__ -D__ARM_ARCH_5TEJ__ -std=gnu99 -D_GNU_SOURCE --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -nostdlib -lm -o conftest
conftest.c:1:18: fatal error: math.h: No such file or directory
#include <math.h>
^
compilation terminated.
--------------------------------------------------
Failed program was:
--------------------------------------------------
#include <math.h>
int main (void) { log2f(2); return 0; }
--------------------------------------------------
checking for strtok_r(0, 0, 0); in string.h... no
Failed commandline was:
--------------------------------------------------
/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc conftest.c -Wall -I. -I$(SRCPATH) --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -march=armv5te -msoft-float -D__ANDROID__ -D__ARM_ARCH_5TE__ -D__ARM_ARCH_5TEJ__ -std=gnu99 -D_GNU_SOURCE --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -nostdlib -lm -o conftest
conftest.c:1:20: fatal error: string.h: No such file or directory
#include <string.h>
^
compilation terminated.
--------------------------------------------------
Failed program was:
--------------------------------------------------
#include <string.h>
int main (void) { strtok_r(0, 0, 0); return 0; }
--------------------------------------------------
checking for clock_gettime(CLOCK_MONOTONIC, 0); in time.h... no
Failed commandline was:
--------------------------------------------------
/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc conftest.c -Wall -I. -I$(SRCPATH) --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -march=armv5te -msoft-float -D__ANDROID__ -D__ARM_ARCH_5TE__ -D__ARM_ARCH_5TEJ__ -std=gnu99 -D_GNU_SOURCE --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -nostdlib -lm -o conftest
conftest.c:1:18: fatal error: time.h: No such file or directory
#include <time.h>
^
compilation terminated.
--------------------------------------------------
Failed program was:
--------------------------------------------------
#include <time.h>
int main (void) { clock_gettime(CLOCK_MONOTONIC, 0); return 0; }
--------------------------------------------------
checking for clock_gettime(CLOCK_MONOTONIC, 0); in time.h... no
Failed commandline was:
--------------------------------------------------
/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc conftest.c -Wall -I. -I$(SRCPATH) --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -march=armv5te -msoft-float -D__ANDROID__ -D__ARM_ARCH_5TE__ -D__ARM_ARCH_5TEJ__ -std=gnu99 -D_GNU_SOURCE -lrt --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -nostdlib -lm -o conftest
conftest.c:1:18: fatal error: time.h: No such file or directory
#include <time.h>
^
compilation terminated.
--------------------------------------------------
Failed program was:
--------------------------------------------------
#include <time.h>
int main (void) { clock_gettime(CLOCK_MONOTONIC, 0); return 0; }
--------------------------------------------------
checking whether defined(MAP_PRIVATE) is true... no
--------------------------------------------------
conftest.c:1:22: fatal error: sys/mman.h: No such file or directory
#include <sys/mman.h>
^
compilation terminated.
--------------------------------------------------
Failed program was:
--------------------------------------------------
#include <sys/mman.h>
#include <unistd.h>
#if !(defined(MAP_PRIVATE))
#error
#endif
--------------------------------------------------
checking for uint32_t test_vec __attribute__ ((vector_size (16))) = {0,1,2,3}; in stdint.h... no
Failed commandline was:
--------------------------------------------------
/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc conftest.c -Wall -I. -I$(SRCPATH) --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -march=armv5te -msoft-float -D__ANDROID__ -D__ARM_ARCH_5TE__ -D__ARM_ARCH_5TEJ__ -std=gnu99 -D_GNU_SOURCE --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -nostdlib -lm -o conftest
In file included from conftest.c:1:0:
/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/include/stdint.h:9:26: fatal error: stdint.h: No such file or directory
# include_next <stdint.h>
^
compilation terminated.
--------------------------------------------------
Failed program was:
--------------------------------------------------
#include <stdint.h>
int main (void) { uint32_t test_vec __attribute__ ((vector_size (16))) = {0,1,2,3}; return 0; }
--------------------------------------------------
checking for stdio.h... no
Failed commandline was:
--------------------------------------------------
/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc conftest.c -Wall -I. -I$(SRCPATH) --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -march=armv5te -msoft-float -D__ANDROID__ -D__ARM_ARCH_5TE__ -D__ARM_ARCH_5TEJ__ -std=gnu99 -D_GNU_SOURCE -fPIC -shared -Wl,-Bsymbolic --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -nostdlib -lm -o conftest
conftest.c:1:19: fatal error: stdio.h: No such file or directory
#include <stdio.h>
^
compilation terminated.
--------------------------------------------------
Failed program was:
--------------------------------------------------
#include <stdio.h>
int main (void) { return 0; }
--------------------------------------------------
checking for -fno-tree-vectorize... yes
checking for fseeko(stdin,0,0); in stdio.h... no
Failed commandline was:
--------------------------------------------------
/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc conftest.c -O3 -ffast-math -Wall -I. -I$(SRCPATH) --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -march=armv5te -msoft-float -D__ANDROID__ -D__ARM_ARCH_5TE__ -D__ARM_ARCH_5TEJ__ -std=gnu99 -D_GNU_SOURCE -fPIC -fomit-frame-pointer -fno-tree-vectorize --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -nostdlib -lm -s -o conftest
conftest.c:1:19: fatal error: stdio.h: No such file or directory
#include <stdio.h>
^
compilation terminated.
--------------------------------------------------
Failed program was:
--------------------------------------------------
#include <stdio.h>
int main (void) { fseeko(stdin,0,0); return 0; }
--------------------------------------------------
checking for fseeko64(stdin,0,0); in stdio.h... no
Failed commandline was:
--------------------------------------------------
/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc conftest.c -O3 -ffast-math -Wall -I. -I$(SRCPATH) --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -march=armv5te -msoft-float -D__ANDROID__ -D__ARM_ARCH_5TE__ -D__ARM_ARCH_5TEJ__ -std=gnu99 -D_GNU_SOURCE -fPIC -fomit-frame-pointer -fno-tree-vectorize --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -nostdlib -lm -s -o conftest
conftest.c:1:19: fatal error: stdio.h: No such file or directory
#include <stdio.h>
^
compilation terminated.
--------------------------------------------------
Failed program was:
--------------------------------------------------
#include <stdio.h>
int main (void) { fseeko64(stdin,0,0); return 0; }
--------------------------------------------------
checking for _fseeki64(stdin,0,0); in stdio.h... no
Failed commandline was:
--------------------------------------------------
/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc conftest.c -O3 -ffast-math -Wall -I. -I$(SRCPATH) --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -march=armv5te -msoft-float -D__ANDROID__ -D__ARM_ARCH_5TE__ -D__ARM_ARCH_5TEJ__ -std=gnu99 -D_GNU_SOURCE -fPIC -fomit-frame-pointer -fno-tree-vectorize --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -nostdlib -lm -s -o conftest
conftest.c:1:19: fatal error: stdio.h: No such file or directory
#include <stdio.h>
^
compilation terminated.
--------------------------------------------------
Failed program was:
--------------------------------------------------
#include <stdio.h>
int main (void) { _fseeki64(stdin,0,0); return 0; }
--------------------------------------------------
checking for -Wshadow... yes
checking for -Wmaybe-uninitialized... yes
platform: ARM
byte order: little-endian
system: LINUX
cli: no
libx264: internal
shared: no
static: yes
asm: no
interlaced: yes
avs: no
lavf: no
ffms: no
mp4: no
gpl: yes
thread: no
opencl: no
filters: crop select_every
lto: no
debug: no
gprof: no
strip: yes
PIC: yes
bit depth: all
chroma format: all
内容类型应自动设置