Edits history of script submission #8877 for ' Delete Post (linkedin)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Linkedin = {
    	token: string
    	apiVersion: string
    }
    
    export async function main(resource: Linkedin, postId: string) {
    	// The URL in script.json points to Legacy API.
    	const encodedPostId = encodeURIComponent(postId)
    	const endpoint = `https://api.linkedin.com/rest/posts/${encodedPostId}`
    
    	const response = await fetch(endpoint, {
    		method: 'DELETE',
    		headers: {
    			Authorization: `Bearer ${resource.token}`,
    			'X-Restli-Protocol-Version': '2.0.0',
    			'LinkedIn-Version': `${resource.apiVersion}`
    		}
    	})
    
    	if (!response.ok) {
    		throw new Error(`HTTP error! status: ${response.status}`)
    	}
    
    	const data = await response.json()
    
    	return data
    }
    

    Submitted by hugo697 689 days ago

  • nativets
    type Linkedin = {
    	token: string
    	apiVersion: string
    }
    
    export async function main(resource: Linkedin, postId: string) {
    	// The URL in script.json points to Legacy API.
    	const encodedPostId = encodeURIComponent(postId)
    	const endpoint = `https://api.linkedin.com/rest/posts/${encodedPostId}`
    
    	const response = await fetch(endpoint, {
    		method: 'DELETE',
    		headers: {
    			Authorization: `Bearer ${resource.token}`,
    			'X-Restli-Protocol-Version': '2.0.0',
    			'LinkedIn-Version': `${resource.apiVersion}`
    		}
    	})
    
    	if (!response.ok) {
    		throw new Error(`HTTP error! status: ${response.status}`)
    	}
    
    	const data = await response.json()
    
    	return data
    }
    

    Submitted by hugo697 689 days ago