'Sending Message with linkedIn api with Headless Chrome Rust getting HTTP 999

I am trying to use headless chrome rust to send post request by request interception, to send message to users, but linkedin denying the service. This is how I am doing it. Have got nothing about this issue from anywhere else. Can anyone please help me is it the right way to do it? Can I use browser to use post an API request, I had to use this as I want to save the context within a human, so that I can mimic a human behavior by adding some random time waits.

            let message_event = json!({
                    "keyVersion": "LEGACY_INBOX",
                    "conversationCreate": {
                        "recipients": [urn_id],
                        "eventCreate": {
                            "value": {
                                "com.linkedin.voyager.messaging.create.MessageCreate": {
                                    "body": message,
                                    "attachments": [],
                                    "attributedBody": {"text": message, "attributes": []},
                                    "mediaAttachments": [],
                                }
                            }
                        },
                        "subtype": "MEMBER_TO_MEMBER"
                    }
            });

            tab.enable_request_interception(Arc::new(
                move |_transport: Arc<Transport>,
                      _session_id: SessionId,
                      intercepted: RequestPausedEvent| {
                    let headers = intercepted.params.request.headers.0.unwrap();
                    let mut header_enteries = Vec::new();
                    for (key, value) in headers.as_object().unwrap().iter() {
                        header_enteries.push(HeaderEntry {
                            name: key.clone(),
                            value: value.clone().to_string(),
                        })
                    }

                    header_enteries.push(HeaderEntry {
                        name: "Connection".to_string(),
                        value: "keep-alive".to_string(),
                    });
                    header_enteries.push(HeaderEntry {
                        name: "Accept-Encoding".to_string(),
                        value: "gzip, deflate, br".to_string(),
                    });
                    header_enteries.push(HeaderEntry {
                        name: "Upgrade-Insecure-Request".to_string(),
                        value: "1".to_string(),
                    });
                    let continue_request = ContinueRequest {
                        request_id: intercepted.params.request_id,
                        url: Some(intercepted.params.request.url.clone()),
                        method: Some("POST".to_string()),
                        post_data: Some(base64::encode(message_event.to_string())),
                        headers: Some(header_enteries),
                        intercept_response: Some(false),
                    };
                    RequestPausedDecision::Continue(Some(continue_request))
                },
            ))
            .unwrap();
            tab.set_default_timeout(Duration::from_secs(60));
            thread::sleep(Duration::from_secs(rand::thread_rng().gen_range(30..50)));
            println!("{}", &url);
            tab.navigate_to(&url).unwrap();

This is the response I get:

Response



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source