doocs / qcloud-im-server-sdk-java

☁ Tencent Cloud IM Server SDK in Java | 腾讯云 IM 服务端 SDK Java 版

Home Page:https://doocs.github.io/qcloud-im-server-sdk-java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

设置用户资料接口中自定义字段设置未生效问题(有时候生效)

heangping opened this issue · comments

设置用户资料接口现在情况是设置昵称,头像,自定义字段等数据时调用接口返回成功,然后调用拉取资料查询,昵称,头像是更新成功的,但是自定义字段更新未成功,自定义字段是正确的key,因为有时候自定义字段是更新成功的,查看了入参都没发现啥问题
okhttp request:

Request{method=POST, url=https://console.tim.qq.com/v4/profile/portrait_set?sdkappid=xxxxx&identifier=administrator&usersig=xxxxx&random=2136887377&contenttype=json, headers=[User-Agent:qcloud-im-server-sdk-java/null(Mac OS X/13.0/aarch64;11.0.14.1)]}

okhttp requestString: {"From_Account":"xxxxxx","ProfileItem":[{"Tag":"Tag_Profile_IM_Nick","Value":"对对对"},{"Tag":"Tag_Profile_IM_Image","Value":"https:/xxxx.oss-cn-shanghai.aliyuncs.com/dams/47ed6184c7ee4ffeb9b6cabd7.png"},{"Tag":"Tag_Profile_Custom_Data","Value":"{"mobileNo":"13311111111","roleNameList":["SA"]}"}]}

okhttp response:

Response{protocol=http/1.1, code=200, message=OK, url=https://console.tim.qq.com/v4/profile/portrait_set?sdkappid=dddd&identifier=administrator&usersig=ddddd*&random=2136887377&contenttype=json}

多次调用接口都是返回成功的,自定义字段实际未生效, 查看入参都没问题,费解 是有什么要注意的吗 im后台设置的用户自定义字段key是 : Tag_Profile_Custom_Data 大小写是注意到了 没啥问题

你可以用 rest api 在线工具试试,看看有没有设置成功

https://tcc.tencentcs.com/im-api-tool/index.html#/v4/profile/portrait_get

同样的参数 用在线工具试了是成功的 所以搞不懂了

大佬 这个httpUtil 里面的详细的日志可以加下么 不然看真实的参数有点麻烦

我本地试了,没自定义字段,是会报错的。

http 请求的数据 {"From_Account":"test1","ProfileItem":[{"Tag":"Tag_Profile_IM_Nick","Value":"MyNickName"},{"Tag":"Tag_Profile_Custom_Data","Value":"123"}]}

PortraitSetResult{errorDisplay='', actionStatus='FAIL', errorInfo='Invalid field: Tag_Profile_Custom_Data. You may not configure custom fields in the console or use the wrong fields.', errorCode=40009}

我配置之后,重新调用 portraitSet 是成功的。

然后 portraitGet 拉取数据,响应结果如下:

PortraitGetResult{errorDisplay='', userProfileItemList=[UserProfileItem{toAccount='test1', profileItemList=[ProfileItem{tag='Tag_Profile_IM_Nick', value='MyNickName'}, ProfileItem{tag='Tag_Profile_Custom_Data', value='123'}], resultCode=0, resultInfo=''}], failAccount=null, actionStatus='OK', errorInfo='', errorCode=0}

可以看到结果返回了自定义的 tag 数据

没啥问题吧,你自查一下?

项目里提供了 JsonUtil.obj2Str(),你可以把请求对象打印一下看看。

好的 多谢 我在看看

嗯好,有问题随时反馈

按照步骤试了下 ok了