Hi All.
I got an error message when uploading the document.
error sending message: document upload failed: Post "https:///mms/document/OVk5iQKFT6By4U...."
Is there any update on WhatsApp?
Hi, i have same error:
Document:
error sending file: document upload failed: Post https:///mms/document/xzQKutUjSM0sxi8knyERrP54HsfI9........: http: no Host in request URL - 15A00A81EA9A432E2545
Image:
error sending file: image upload failed: Post https:///mms/image/-1LyWYkUoE42QWJd2D90fHMdtx55B........: http: no Host in request URL - D42BCD7E59FC5B5DA8E5
i need help :(
I confirm same error
time="2020-05-20T05:47:18Z" level=info msg="document upload failed: Post https:///mms/document/6zgmpJk4OkeA5zs8iauv4STBYdHsnVK4rlDd_khh0Zo=?auth=&token=6zgmpJk4OkeA5zs8iauv4STBYdHsnVK4rlDd_khh0Zo%3D: http: no Host in request URL"
time="2020-05-20T05:47:31Z" level=info msg="Doc {{FFB126614D072AA49479923783FCA6C6 [email protected] false 1589953651 0 <nil>} string 0 application/pdf [] 0xb096280 [] [] [] 0 { <nil> false}}"
I have a lot of errors once sending, since i tried in loop, but at the end the document sent... I am not sure what is the problem...
I have a lot of errors once sending, since i tried in loop, but at the end the document sent... I am not sure what is the problem...
You try to sent many times inside de loop and passed ok!?
I have a lot of errors once sending, since i tried in loop, but at the end the document sent... I am not sure what is the problem...
You try to sent many times inside de loop and passed ok!?
Yes, but it seems a bug since i tried it no with image but it did not works.
Keep log errors
I have a lot of errors once sending, since i tried in loop, but at the end the document sent... I am not sure what is the problem...
You try to sent many times inside de loop and passed ok!?
Yes, but it seems a bug since i tried it no with image but it did not works.
Keep log errors
I verified that it is not mounting the URL correctly, uploading
I believe the problem here
https://github.com/Rhymen/go-whatsapp/blob/2f227c53b44f4011dc3f87ce552d190b036a9bca/media.go#L178
Correct?
I believe the problem here
https://github.com/Rhymen/go-whatsapp/blob/2f227c53b44f4011dc3f87ce552d190b036a9bca/media.go#L178Correct?
yes. line 72. hostname, auth, _, err := wac.queryMediaConn()
I believe the problem here
https://github.com/Rhymen/go-whatsapp/blob/2f227c53b44f4011dc3f87ce552d190b036a9bca/media.go#L178Correct?
yes. line 72. hostname, auth, _, err := wac.queryMediaConn()
I am out of the office, please try to log
https://github.com/Rhymen/go-whatsapp/blob/2f227c53b44f4011dc3f87ce552d190b036a9bca/media.go#L110
Lets see if the json changed
I found same issue.
I try debug and i found response mediaConn like this
media_conn: {auth: "xxxx", ttl: 21600,…}
auth: "xxxxx"
hosts: [{hostname: "media-xsp1-1.cdn.whatsapp.net",…}, {hostname: "mmg.whatsapp.net", ips: []}]
0: {hostname: "media-xsp1-1.cdn.whatsapp.net",…}
hostname: "media-xsp1-1.cdn.whatsapp.net"
ips: [{ip4: "157.240.217.60", ip6: "2a03:2880:f25c:c3:face:b00c:0:167"}]
0: {ip4: "157.240.217.60", ip6: "2a03:2880:f25c:c3:face:b00c:0:167"}
1: {hostname: "mmg.whatsapp.net", ips: []}
hostname: "mmg.whatsapp.net"
ips: []
ttl: 21600
status: 200
I try change MediaConn struct in file media.go from
type MediaConn struct {
Status int `json:"status"`
MediaConn struct {
Auth string `json:"auth"`
TTL int `json:"ttl"`
Hosts []struct {
Hostname string `json:"hostname"`
IPs []string `json:"ips"`
} `json:"hosts"`
} `json:"media_conn"`
}
To
type MediaConn struct {
Status int `json:"status"`
MediaConn struct {
Auth string `json:"auth"`
TTL int `json:"ttl"`
Hosts []struct {
Hostname string `json:"hostname"`
IPs []struct {
IP4 string `json:"ip4"`
IP6 string `json:"ip6"`
} `json:"ips"`
} `json:"hosts"`
} `json:"media_conn"`
}
And it works.
Thanks
Thanks, It works :)
@Rhymen update please
Thanks!!!
Works here too!!
thanks it works!
@ramacatur i note some time the old struct works but most of the time it is not, can we use both and assign the correct one base on the resp?
@ramacatur i note some time the old struct works but most of the time it is not, can we use both and assign the correct one base on the resp?
You can use type interface{}
type MediaConn struct {
Status int `json:"status"`
MediaConn struct {
Auth string `json:"auth"`
TTL int `json:"ttl"`
Hosts []struct {
Hostname string `json:"hostname"`
IPs []interface{} `json:"ips"`
} `json:"hosts"`
} `json:"media_conn"`
}
and it works for old struct
And what is the interface?
@ramacatur, sorry l am new to golang
And what is the interface?
@ramacatur, sorry l am new to golang
An empty interface (interface{}) may hold values of any type. (Every type implements at least zero methods.) (https://tour.golang.org/methods/14)
so response string or object, like on this case, can be represented by empy interface - interface{}
And what is the interface?
@ramacatur, sorry l am new to golangAn empty interface (
interface{}) may hold values of any type. (Every type implements at least zero methods.) (https://tour.golang.org/methods/14)so response string or object, like on this case, can be represented by empy interface -
interface{}
Thanks, but what the benefits of the json:"ips", it works without it...
And what is the interface?
@ramacatur, sorry l am new to golangAn empty interface (
interface{}) may hold values of any type. (Every type implements at least zero methods.) (https://tour.golang.org/methods/14)
so response string or object, like on this case, can be represented by empy interface -interface{}Thanks, but what the benefits of the
json:"ips", it works without it...
Yes it works, but for best code you must add json:"ips". Json tag for mapping from json data to struct.
Response from mediaConn like this
media_conn: {auth: "xxxx", ttl: 21600,…}
auth: "xxxxx"
hosts: [{hostname: "media-xsp1-1.cdn.whatsapp.net",…}, {hostname: "mmg.whatsapp.net", ips: []}]
0: {hostname: "media-xsp1-1.cdn.whatsapp.net",…}
hostname: "media-xsp1-1.cdn.whatsapp.net"
**ips**: [{ip4: "157.240.217.60", ip6: "2a03:2880:f25c:c3:face:b00c:0:167"}]
0: {ip4: "157.240.217.60", ip6: "2a03:2880:f25c:c3:face:b00c:0:167"}
1: {hostname: "mmg.whatsapp.net", ips: []}
hostname: "mmg.whatsapp.net"
ips: []
ttl: 21600
status: 200
to mapping ips to struct you can use tag json:"ips"
So if you change code like this
type MediaConn struct {
Status int `json:"status"`
MediaConn struct {
Auth string `json:"auth"`
TTL int `json:"ttl"`
Hosts []struct {
Hostname string `json:"hostname"`
Anything []internface{} `json:"ips"`
} `json:"hosts"`
} `json:"media_conn"`
}
It works for parsing json in golang.
Most helpful comment
I found same issue.
I try debug and i found response mediaConn like this
I try change
MediaConn structin file media.go fromTo
And it works.
Thanks